files

package
v0.0.0-...-17d9b22 Latest Latest
Warning

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

Go to latest
Published: Nov 18, 2022 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const JSON string = "json"
View Source
const PathSeparator = string(os.PathSeparator)
View Source
const YAML string = "yaml"
View Source
const YML string = "yml"

Variables

This section is empty.

Functions

func CheckAndCreateDir

func CheckAndCreateDir(path string)

func CreateDirIfNotExist

func CreateDirIfNotExist(path string) (existed bool, err error)

func CreateFile

func CreateFile(filename string, path string) (file *os.File)

func DeleteFileOrDir

func DeleteFileOrDir(path string)

func FileIsJson

func FileIsJson(filename string) bool

func FileIsYaml

func FileIsYaml(filename string) bool

func GetAbsPath

func GetAbsPath(path string) string

func LoadYamlFileToStruct

func LoadYamlFileToStruct[T any](path string) (*T, error)

func OpenFileAtPath

func OpenFileAtPath(path string, homepath string) (reader *os.File, err error)

func PathExists

func PathExists(filePath string) (exists bool)

func RemoveDir

func RemoveDir(path string)

func WriteStringContentsToFile

func WriteStringContentsToFile(path string, contents string, force bool) error

func WriteStructToFile

func WriteStructToFile(target any, filename string, path string)

func WriteStructsToFile

func WriteStructsToFile(target any, filename string, path string, createDir bool) (exportCnt int)

Types

type FileDecoder

type FileDecoder interface {
	Decode(v any) error
}

type FileEncoder

type FileEncoder interface {
	Encode(v any) (err error)
}

type FileInfo

type FileInfo struct {
	Name        string
	BaseAbsPath string
	Info        os.FileInfo
	IsDir       bool
}

func GetDirsAtPath

func GetDirsAtPath(path string, createIfNotExit bool) (results []*FileInfo)

func GetFilesAtPath

func GetFilesAtPath(path string, excludeDirs bool) (results []*FileInfo)

func NewFileInfo

func NewFileInfo(name string, absPath string) *FileInfo

func NewFileInfoFromPath

func NewFileInfoFromPath(path string) *FileInfo

func (*FileInfo) AbsFilePath

func (fi *FileInfo) AbsFilePath() string

func (*FileInfo) Exists

func (fi *FileInfo) Exists() bool

func (*FileInfo) GetFileInfo

func (fi *FileInfo) GetFileInfo(name string, absPath string) os.FileInfo

func (*FileInfo) MoveToPath

func (fi *FileInfo) MoveToPath(path string)

func (*FileInfo) Open

func (fi *FileInfo) Open() (*os.File, error)

func (*FileInfo) OpenForReading

func (fi *FileInfo) OpenForReading() *os.File

func (*FileInfo) OpenForWriting

func (fi *FileInfo) OpenForWriting(truncate bool) *os.File

Jump to

Keyboard shortcuts

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