shared

package
v0.0.77 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 27, 2023 License: MIT Imports: 14 Imported by: 6

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CheckDirectory

func CheckDirectory(ctx context.Context, dir string) (bool, error)

CheckDirectory is a safer version of DirectoryExists return bool, err err only for unexpected behavior

func CheckDirectoryOrCreate

func CheckDirectoryOrCreate(ctx context.Context, dir string) (bool, error)

CheckDirectoryOrCreate checks if a directory exists or create it if it doesn't bool: created err: only for unexpected behavior

func CheckEmptyDirectoryOrCreate

func CheckEmptyDirectoryOrCreate(ctx context.Context, dir string) (bool, error)

CheckEmptyDirectoryOrCreate checks if a directory exists and is empty bool if created err only for unexpected behavior or if exists

func CopyFile

func CopyFile(_ context.Context, from string, to string) error

func DefaultTo added in v0.0.51

func DefaultTo(s string, defaultValue string) string

func DirectoryExists added in v0.0.13

func DirectoryExists(p string) bool

func FileExists

func FileExists(file string) bool

func Must added in v0.0.42

func Must[T any](t T, err error) T

func Pointer added in v0.0.51

func Pointer[T any](t T) *T

func PointerEqual added in v0.0.51

func PointerEqual[T comparable](t *T, target T) bool

PointerEqual returns true if pointer is not nil and value is equal

func ProtoType added in v0.0.51

func ProtoType(m proto.Message) string

func ToCamelCase added in v0.0.51

func ToCamelCase(s string) string

ToCamelCase converts a string to camelCase

func ToDNSCase added in v0.0.51

func ToDNSCase(s string) string

func ToKebabCase added in v0.0.51

func ToKebabCase(str string) string

ToKebabCase converts a string to kebab-case

func ToLowerCase added in v0.0.51

func ToLowerCase(s string) string

func ToSnakeCase added in v0.0.51

func ToSnakeCase(s string) string

ToSnakeCase converts a string to snake_case

func ToTitle added in v0.0.51

func ToTitle(s string) string

func TypeOf added in v0.0.51

func TypeOf[T any]() string

func WithIgnore added in v0.0.51

func WithIgnore(ctx context.Context, ignore Ignore) context.Context

func WithOverride added in v0.0.51

func WithOverride(ctx context.Context, override Override) context.Context

Types

type Case added in v0.0.51

type Case struct {
	LowerCase string
	SnakeCase string
	CamelCase string
	KebabCase string
	DNSCase   string
	Title     string
}

func ToCase added in v0.0.51

func ToCase(s string) Case

type ContextIgnoreKey added in v0.0.51

type ContextIgnoreKey string
const (
	IgnoreKey ContextIgnoreKey = "ignore"
)

type ContextOverrideKey added in v0.0.51

type ContextOverrideKey string
const (
	OverrideKey ContextOverrideKey = "override"
)

type CopyInstruction

type CopyInstruction struct {
	Name string
	Path string
}

type Dir

type Dir struct {
	// contains filtered or unexported fields
}

func Local

func Local(dir string) (*Dir, error)

func MustLocal

func MustLocal(dir string) Dir

func NewDir

func NewDir(dir string, args ...any) Dir

func (*Dir) Absolute

func (d *Dir) Absolute() string

func (*Dir) Join

func (d *Dir) Join(other Dir) Dir

func (*Dir) Relative

func (d *Dir) Relative() string

func (*Dir) RelativeFrom

func (d *Dir) RelativeFrom(base Dir) (*Dir, error)

type DirReader added in v0.0.13

type DirReader struct {
	// contains filtered or unexported fields
}

func NewDirReader added in v0.0.13

func NewDirReader() *DirReader

func (*DirReader) AbsoluteDir added in v0.0.13

func (dr *DirReader) AbsoluteDir(dir Dir) string

func (*DirReader) AbsoluteFile added in v0.0.13

func (dr *DirReader) AbsoluteFile(f File) string

func (*DirReader) At added in v0.0.13

func (dr *DirReader) At(root string) *DirReader

func (*DirReader) ReadDir added in v0.0.13

func (dr *DirReader) ReadDir(dir Dir) ([]os.DirEntry, error)

func (*DirReader) ReadFile added in v0.0.13

func (dr *DirReader) ReadFile(f File) ([]byte, error)

type FSReader added in v0.0.13

type FSReader struct {
	FS fs.FS
	// contains filtered or unexported fields
}

func Embed added in v0.0.13

func Embed(fsys fs.FS) *FSReader

func (*FSReader) Absolute added in v0.0.13

func (fr *FSReader) Absolute(dir Dir) string

func (*FSReader) AbsoluteDir added in v0.0.13

func (fr *FSReader) AbsoluteDir(dir Dir) string

func (*FSReader) AbsoluteFile added in v0.0.13

func (fr *FSReader) AbsoluteFile(f File) string

func (*FSReader) At added in v0.0.13

func (fr *FSReader) At(root string) *FSReader

func (*FSReader) Copy added in v0.0.13

func (fr *FSReader) Copy(s string, file string) error

func (*FSReader) ReadDir added in v0.0.13

func (fr *FSReader) ReadDir(dir Dir) ([]os.DirEntry, error)

func (*FSReader) ReadFile added in v0.0.13

func (fr *FSReader) ReadFile(f File) ([]byte, error)

type File

type File struct {
	// contains filtered or unexported fields
}

func NewFile

func NewFile(file string) File

func (*File) Base

func (f *File) Base() string

func (*File) Relative

func (f *File) Relative() string

func (*File) RelativeFrom

func (f *File) RelativeFrom(base Dir) (*File, error)

func (*File) RelativePath

func (f *File) RelativePath() string

type FileSystem added in v0.0.13

type FileSystem interface {
	AbsoluteFile(f File) string
	AbsoluteDir(dir Dir) string
	ReadDir(dir Dir) ([]os.DirEntry, error)
	ReadFile(file File) ([]byte, error)
}

type Ignore added in v0.0.51

type Ignore interface {
	Skip(p string) bool
}

func GetIgnore added in v0.0.51

func GetIgnore(ctx context.Context) Ignore

func IgnoreNone added in v0.0.51

func IgnoreNone() Ignore

type IgnoreNoneHandler added in v0.0.51

type IgnoreNoneHandler struct{}

func (IgnoreNoneHandler) Skip added in v0.0.51

func (i IgnoreNoneHandler) Skip(string) bool

type IgnorePatterns added in v0.0.51

type IgnorePatterns struct {
	// contains filtered or unexported fields
}

func NewIgnore added in v0.0.51

func NewIgnore(patterns ...string) IgnorePatterns

func (IgnorePatterns) Skip added in v0.0.51

func (ign IgnorePatterns) Skip(file string) bool

type Override added in v0.0.13

type Override interface {
	Replace(p string) bool
}

func GetOverride added in v0.0.51

func GetOverride(ctx context.Context) Override

func SilentOverride added in v0.0.51

func SilentOverride() Override

func Skip added in v0.0.51

func Skip() Override

type Replacement

type Replacement struct {
	From string `yaml:"from"`
	To   string `yaml:"to"`
}

type S added in v0.0.13

type S = string

type SilentOverrideHandler added in v0.0.51

type SilentOverrideHandler struct{}

func (SilentOverrideHandler) Replace added in v0.0.51

func (s SilentOverrideHandler) Replace(string) bool

type SkipOverrideHandler added in v0.0.51

type SkipOverrideHandler struct{}

func (SkipOverrideHandler) Replace added in v0.0.51

func (s SkipOverrideHandler) Replace(string) bool

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL