Documentation
¶
Index ¶
- Constants
- Variables
- func CD(dir string) func()
- func DirExists(path string) bool
- func Escape(name string) string
- func ExecutableExt() string
- func Exists(path string) bool
- func FileExists(path string) bool
- func HomeDir() string
- func Mkdir(path string, options *MkdirOptions) error
- func Move(from, to string, perm *os.FileMode) error
- func OutputFile(p string, data interface{}, options *OutputFileOptions) error
- func ReadFile(p string) ([]byte, error)
- func ReadJSON(p string, data interface{}) error
- func ReadString(p string) (string, error)
- func Remove(patterns ...string) error
- func RemoveWithDir(dir string, patterns ...string) error
- func RetryPanic(times int, wait time.Duration, fn func()) (errs []interface{})
- func SendSigInt(pid int) error
- func WaitSignal(signals ...os.Signal)
- type Matcher
- type MkdirOptions
- type OutputFileOptions
- type WalkContext
- func (ctx *WalkContext) Dir(d string) *WalkContext
- func (ctx *WalkContext) Do(cb WalkFunc) error
- func (ctx *WalkContext) FollowSymbolicLinks() *WalkContext
- func (ctx *WalkContext) List() ([]string, error)
- func (ctx *WalkContext) Matcher(m *Matcher) *WalkContext
- func (ctx *WalkContext) MustList() []string
- func (ctx *WalkContext) PostChildrenCallback(cb WalkFunc) *WalkContext
- func (ctx *WalkContext) Sort() *WalkContext
- type WalkDirent
- type WalkFunc
Constants ¶
const WalkGitIgnore = "!g"
WalkGitIgnore special pattern to ignore all gitignore rules, including the ".gitignore" and ".gitignore_global"
const WalkIgnoreHidden = "!**" + string(os.PathSeparator) + ".[^.]*"
WalkIgnoreHidden special pattern to ignore all hidden files
Variables ¶
var Chmod = acl.Chmod
Chmod ...
var Copy = copy.Copy
Copy file or dir recursively
Functions ¶
func CD ¶ added in v0.22.1
func CD(dir string) func()
CD to a dir and return a function to cd back to the preivous dir
func Escape ¶ added in v0.21.2
Escape file name based on the os. Half-width illegal char will be replaced with its full-width version.
func FileExists ¶
FileExists checks if file exists, only for file, not for dir
func OutputFile ¶
func OutputFile(p string, data interface{}, options *OutputFileOptions) error
OutputFile auto creates file if not exists, it will try to detect the data type and auto output binary, string or json
func RemoveWithDir ¶ added in v0.18.3
RemoveWithDir is the low level of Remove
func RetryPanic ¶ added in v0.21.0
RetryPanic retry function after a duration for several times, if success returns nil
func WaitSignal ¶
WaitSignal block until get specified os signals
Types ¶
type OutputFileOptions ¶
type OutputFileOptions struct { DirPerm os.FileMode FilePerm os.FileMode JSONPrefix string JSONIndent string }
OutputFileOptions ...
type WalkContext ¶
type WalkContext struct {
// contains filtered or unexported fields
}
WalkContext ...
func Walk ¶
func Walk(patterns ...string) *WalkContext
Walk Set up the walk, need to call Do to actually run it. If the pattern begins with "!", it will become a negative filter pattern. Each path will be tested against all pattern, each pattern will override the previous pattern's match result.
func (*WalkContext) FollowSymbolicLinks ¶
func (ctx *WalkContext) FollowSymbolicLinks() *WalkContext
FollowSymbolicLinks ...
func (*WalkContext) List ¶
func (ctx *WalkContext) List() ([]string, error)
List walk and get list of the paths
func (*WalkContext) PostChildrenCallback ¶
func (ctx *WalkContext) PostChildrenCallback(cb WalkFunc) *WalkContext
PostChildrenCallback ...
func (*WalkContext) Sort ¶
func (ctx *WalkContext) Sort() *WalkContext
Sort whether to sort the result or not