file

package
v0.12.1 Latest Latest
Warning

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

Go to latest
Published: Apr 24, 2023 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CopyFile

func CopyFile(srcFile, dstFile string) (err error)

func CreateTempDir added in v0.10.0

func CreateTempDir(dirPattern string) (string, error)

func DirFileFilterDefaultFunc added in v0.10.2

func DirFileFilterDefaultFunc(filePath string, isDir bool) bool

DirFileFilterDefaultFunc is used for GetFileMap it will return false if isDir is true

func GenerateAbsFilePath added in v0.10.0

func GenerateAbsFilePath(baseDir, file string) (string, error)

GenerateAbsFilePath return all the path with a given file name

func GetFileAbsDirPath added in v0.10.0

func GetFileAbsDirPath(fileLoc string) (string, error)

GetFileAbsDirPath will return abs dir path for file

func GetFileAbsDirPathOrDirItself added in v0.10.3

func GetFileAbsDirPathOrDirItself(fileLoc string) (string, error)

GetFileAbsDirPathOrDirItself will return abs dir path, for file: return its parent directory for directory: return dir itself

func GetFileMap added in v0.10.0

func GetFileMap(
	srcPath string, filterFunc DirFileFilterFunc, fileNameFunc DirFileNameFunc, fileContentFunc DirFileContentFunc,
) (map[string][]byte, error)

GetFileMap return map of fileName and content if srcPath is a directory, it will invoke GetFileMapByWalkDir to get content map if srcPath is a file, it will use fileNameFunc and fileContentFunc to create a map

func GetFileMapByWalkDir added in v0.10.0

func GetFileMapByWalkDir(
	srcPath string, filterFunc DirFileFilterFunc, fileNameFunc DirFileNameFunc, processFunc DirFileContentFunc,
) (map[string][]byte, error)

GetFileMapByWalkDir will walk in directory return contentMap

func GetYamlNodeStrByPath added in v0.10.0

func GetYamlNodeStrByPath(content []byte, path string) (string, error)

GetYamlNodeStrByPath get element from yaml content by yaml path return string format of node

func ReadYamls added in v0.10.3

func ReadYamls(path string) ([]byte, error)

ReadYamls reads file or files from dir whose suffix is yaml or yml and returns the content of the files without "---" separator

func RemoveFileIfExists added in v0.10.0

func RemoveFileIfExists(filename string) error

func ReplaceAppNameInPathStr added in v0.9.0

func ReplaceAppNameInPathStr(filePath, appNamePlaceHolder, appName string) string

Types

type DirFileContentFunc added in v0.10.0

type DirFileContentFunc func(filePath string) ([]byte, error)

DirFileContentFunc is used to get file content then return this content

type DirFileFilterFunc added in v0.10.3

type DirFileFilterFunc func(filePath string, isDir bool) bool

DirFileFilterFunc is used to filter files when walk directory if this func return false, this file's content will not return

type DirFileNameFunc added in v0.9.0

type DirFileNameFunc func(filePath, srcPath string) string

DirFileNameFunc is used to make current filename to become map key srcPath is the basePath of file, for sometimes you may want to get relativePath of filePath

type YamlSequenceNode added in v0.10.0

type YamlSequenceNode struct {
	StrOrigin string
	StrArray  []string
}

YamlSequenceNode is yaml sequenceNode

func GetYamlNodeArrayByPath added in v0.10.0

func GetYamlNodeArrayByPath(content []byte, path string) (*YamlSequenceNode, error)

GetYamlNodeArrayByPath get element from yaml content by yaml path return string array for elements

func MergeYamlNode added in v0.10.0

func MergeYamlNode(dst *YamlSequenceNode, src *YamlSequenceNode) *YamlSequenceNode

func (*YamlSequenceNode) IsEmpty added in v0.10.0

func (n *YamlSequenceNode) IsEmpty() bool

IsEmpty check node fields are empty

Jump to

Keyboard shortcuts

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