Documentation
¶
Index ¶
- Variables
- func Assert(params ...interface{})
- func CreateFile(fs afero.Fs, name, content string) error
- func FileSize(fs afero.Fs, name string) int64
- func FileSize2(fs afero.Fs, name string) (int64, error)
- func First[T any](first T, rest ...interface{}) T
- func GetEnvDefault(key, defaultValue string) string
- func GetFirstSubdir(root, path string) string
- func IsAbs(path string) bool
- func IsKeyBlacklisted(key string) bool
- func IsKeyValueBlacklisted(key string) bool
- func IsSecureFileName(name string) bool
- func IsValidID(s string) bool
- func LeadingDigits(s string) string
- func MoveFile(src afero.Fs, oldname string, dst afero.Fs, newname string) error
- func NewValidator(fs afero.Fs) *validator.Validate
- func NoSuchFile(fs afero.Fs, name string) bool
- type ErrNoSuchDirectory
- type Error
- type ErrorCode
Constants ¶
This section is empty.
Variables ¶
View Source
var Validate *validator.Validate = NewValidator(afero.NewOsFs())
Functions ¶
func CreateFile ¶
CreateFile creates file name and writes there content. The file must not exists.
func GetEnvDefault ¶
func GetFirstSubdir ¶
GetFirstSubdir returns first directory name after root Example: input is '/mnt/input/project' if path is '/mnt/input/project/1234.crc' then return is ” if path is '/mnt/input/project/rel-4.2.2/1234.crc' then return is 'rel-4.2.2'
func IsAbs ¶
IsAbs covers problem of filepath.IsAbs which only checks first element of path and allows .. inside. The filepath.Abs meanwhile does filepath.Clean. So this function returns true, if filepath.Abs returns very same value
func IsKeyBlacklisted ¶
func IsKeyValueBlacklisted ¶
func IsSecureFileName ¶
IsSecureFileName checking the file name does not have some hacks in it TODO Is ":" good one to block some windows hacks?
func LeadingDigits ¶
func NewValidator ¶
Types ¶
type ErrNoSuchDirectory ¶
type ErrNoSuchDirectory struct {
Path string
}
func (ErrNoSuchDirectory) Error ¶
func (e ErrNoSuchDirectory) Error() string
Source Files
¶
Click to show internal directories.
Click to hide internal directories.