lib

package
v0.0.5 Latest Latest
Warning

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

Go to latest
Published: Nov 12, 2024 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Validate *validator.Validate = NewValidator(afero.NewOsFs())

Functions

func Assert

func Assert(params ...interface{})

The params may be: - error - bool, string

func CreateFile

func CreateFile(fs afero.Fs, name, content string) error

CreateFile creates file name and writes there content. The file must not exists.

func FileSize

func FileSize(fs afero.Fs, name string) int64

FileSize returns size of file or zero

func FileSize2

func FileSize2(fs afero.Fs, name string) (int64, error)

FileSize2 returns size of file or error

func First

func First[T any](first T, rest ...interface{}) T

func GetEnvDefault

func GetEnvDefault(key, defaultValue string) string

func GetFirstSubdir

func GetFirstSubdir(root, path string) string

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

func IsAbs(path string) bool

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 IsKeyBlacklisted(key string) bool

func IsKeyValueBlacklisted

func IsKeyValueBlacklisted(key string) bool

func IsSecureFileName

func IsSecureFileName(name string) bool

IsSecureFileName checking the file name does not have some hacks in it TODO Is ":" good one to block some windows hacks?

func IsValidID

func IsValidID(s string) bool

func LeadingDigits

func LeadingDigits(s string) string

func MoveFile

func MoveFile(src afero.Fs, oldname string, dst afero.Fs, newname string) error

func NewValidator

func NewValidator(fs afero.Fs) *validator.Validate

func NoSuchFile

func NoSuchFile(fs afero.Fs, name string) bool

NoSuchFile return true if file name does not exists

Types

type ErrNoSuchDirectory

type ErrNoSuchDirectory struct {
	Path string
}

func (ErrNoSuchDirectory) Error

func (e ErrNoSuchDirectory) Error() string

type Error

type Error string

func (Error) Error

func (e Error) Error() string

type ErrorCode

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

func NewErrorCode

func NewErrorCode(err error, code int) ErrorCode

func (*ErrorCode) Code

func (e *ErrorCode) Code() int

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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