Documentation ¶
Index ¶
- func EnsurePathAt(path, defaultFilename string, perm int, vfs ...storage.VirtualFS) (at string, err error)
- func Exists(path string) bool
- func FileExists(path string) bool
- func FolderExists(path string) bool
- func IsNil(i interface{}) bool
- func Must(err error)
- func ResolvePath(path string, mocks ...ResolveMocks) string
- func SplitParent(path string) (d, f string)
- type AbsFunc
- type HomeUserFunc
- type PutProp
- type PutPropFactory
- type ResolveMocks
- type RoProp
- type RoPropFactory
- type RwProp
- type RwPropFactory
- type VarProp
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func EnsurePathAt ¶ added in v0.5.4
func EnsurePathAt(path, defaultFilename string, perm int, vfs ...storage.VirtualFS) (at string, err error)
EnsurePathAt ensures that the specified path exists (including any non existing intermediate directories). Given a path and a default filename, the specified path is created in the following manner: - If the path denotes a file (path does not end is a directory separator), then the parent folder is created if it doesn't exist on the file-system provided. - If the path denotes a directory, then that directory is created.
The returned string represents the file, so if the path specified was a directory path, then the defaultFilename provided is joined to the path and returned, otherwise the original path is returned un-modified. Note: filepath.Join does not preserve a trailing separator, therefore to make sure a path is interpreted as a directory and not a file, then the separator has to be appended manually onto the end of the path. If vfs is not provided, then the path is ensured directly on the native file system.
func Exists ¶
Exists provides a simple way to determine whether the item identified by a path actually exists either as a file or a folder
func FileExists ¶
FileExists provides a simple way to determine whether the item identified by a path actually exists as a file
func FolderExists ¶
FileExists provides a simple way to determine whether the item identified by a path actually exists as a folder
func ResolvePath ¶ added in v0.2.0
func ResolvePath(path string, mocks ...ResolveMocks) string
ResolvePath performs 2 forms of path resolution. The first is resolving a home path reference, via the ~ character; ~ is replaced by the user's home path. The second resolves ./ or ../ relative path. The overrides do not need to be provided.
func SplitParent ¶
Types ¶
type AbsFunc ¶ added in v0.2.0
AbsFunc signature of function used to obtain the absolute representation of a path.
type HomeUserFunc ¶ added in v0.2.0
HomeUserFunc signature of function used to obtain the user's home directory.
func (HomeUserFunc) Home ¶ added in v0.2.0
func (f HomeUserFunc) Home() (string, error)
Home function invoker, allows a function to be used in place where an instance of an interface would be expected.
type PutProp ¶
PutProp putter variable property interface. The putter allows the client to define assignment using a client defined function. The putter will still set the property's Field value.
func NewPutProp ¶
NewPutProp create putter variable property
func NewPutPropZ ¶
NewPutProp create putter variable and zeroable property
type PutPropFactory ¶
PutPropFactory putter variable property factory
func (PutPropFactory[T]) New ¶
func (f PutPropFactory[T]) New(value T, putter func(value T)) PutProp[T]
New putter variable property constructor
type ResolveMocks ¶ added in v0.2.0
type ResolveMocks struct { HomeFunc HomeUserFunc AbsFunc AbsFunc }
ResolveMocks, used to override the internal functions used to resolve the home path (os.UserHomeDir) and the abs path (filepath.Abs). In normal usage, these do not need to be provided, just used for testing purposes.
type RoPropFactory ¶
RoPropFactory const property factory
func (RoPropFactory[T]) New ¶
func (f RoPropFactory[T]) New(value T) RoProp[T]
New const property constructor
type RwProp ¶
RwProp variable property interface
func NewRwPropZ ¶
NewRwProp create variable and zeroable property
type RwPropFactory ¶
RwPropFactory variable property factory
func (RwPropFactory[T]) New ¶
func (f RwPropFactory[T]) New(value T) RwProp[T]
New variable property constructor
type VarProp ¶
type VarProp[T any] struct { Field T // contains filtered or unexported fields }
VarProp a read/write property
func (*VarProp[T]) IsZeroable ¶
IsZeroable indicates whether a zero value is a valid value for this property