os

package
v0.25.11 Latest Latest
Warning

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

Go to latest
Published: Oct 18, 2020 License: MIT Imports: 17 Imported by: 0

Documentation

Index

Constants

View Source
const WalkGitIgnore = "!g"

WalkGitIgnore special pattern to ignore all gitignore rules, including the ".gitignore" and ".gitignore_global"

View Source
const WalkIgnoreHidden = "!**" + string(os.PathSeparator) + ".[^.]*"

WalkIgnoreHidden special pattern to ignore all hidden files

Variables

View Source
var Chmod = acl.Chmod

Chmod ...

View Source
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 DirExists

func DirExists(path string) bool

DirExists checks if file exists, only for dir, not for file

func Escape added in v0.21.2

func Escape(name string) string

Escape file name based on the os. Half-width illegal char will be replaced with its full-width version.

func ExecutableExt

func ExecutableExt() string

ExecutableExt ...

func Exists

func Exists(path string) bool

Exists checks if file or dir exists

func FileExists

func FileExists(path string) bool

FileExists checks if file exists, only for file, not for dir

func HomeDir

func HomeDir() string

HomeDir returns the current user's home dir path

func Mkdir

func Mkdir(path string, options *MkdirOptions) error

Mkdir makes dir recursively

func Move

func Move(from, to string, perm *os.FileMode) error

Move file or folder to another location, create path if needed

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 ReadFile

func ReadFile(p string) ([]byte, error)

ReadFile reads file as bytes

func ReadJSON

func ReadJSON(p string, data interface{}) error

ReadJSON reads file as json

func ReadString

func ReadString(p string) (string, error)

ReadString reads file as string

func Remove

func Remove(patterns ...string) error

Remove dirs, files, patterns as expected.

func RemoveWithDir added in v0.18.3

func RemoveWithDir(dir string, patterns ...string) error

RemoveWithDir is the low level of Remove

func RetryPanic added in v0.21.0

func RetryPanic(times int, wait time.Duration, fn func()) (errs []interface{})

RetryPanic retry function after a duration for several times, if success returns nil

func SendSigInt

func SendSigInt(pid int) error

SendSigInt ...

func WaitSignal

func WaitSignal(signals ...os.Signal)

WaitSignal block until get specified os signals

Types

type Matcher

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

Matcher ...

func NewMatcher

func NewMatcher(dir string, patterns []string) *Matcher

NewMatcher ...

func (*Matcher) Match

func (m *Matcher) Match(p string, isDir bool) (matched, negative bool, err error)

Match ...

type MkdirOptions

type MkdirOptions struct {
	Perm os.FileMode
}

MkdirOptions ...

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) Dir

func (ctx *WalkContext) Dir(d string) *WalkContext

Dir set dir

func (*WalkContext) Do

func (ctx *WalkContext) Do(cb WalkFunc) error

Do execute walk

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) Matcher

func (ctx *WalkContext) Matcher(m *Matcher) *WalkContext

Matcher ...

func (*WalkContext) MustList

func (ctx *WalkContext) MustList() []string

MustList ...

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

type WalkDirent

type WalkDirent = *godirwalk.Dirent

WalkDirent ...

type WalkFunc

type WalkFunc = godirwalk.WalkFunc

WalkFunc ...

Jump to

Keyboard shortcuts

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