Documentation ¶
Overview ¶
Package ccgo collects utilities often used while generating code with ccgo.
Index ¶
- func AbsCwd() (string, error)
- func CopyDir(dst, src string, canOverwrite func(fn string, fi os.FileInfo) bool) (files int, bytes int64, rerr error)
- func CopyFile(dst, src string, canOverwrite func(fn string, fi os.FileInfo) bool) (n int64, rerr error)
- func Env(key, dflt string) string
- func Fatal(stackTrace bool, args ...interface{})
- func Fatalf(stackTrace bool, s string, args ...interface{})
- func InDir(dir string, f func() error) (err error)
- func Mkdirs(paths ...string) error
- func MustAbsCwd(stackTrace bool) string
- func MustCopyDir(stackTrace bool, dst, src string, ...) (files int, bytes int64)
- func MustCopyFile(stackTrace bool, dst, src string, ...) int64
- func MustInDir(stackTrace bool, dir string, f func() error)
- func MustMkdirs(stackTrace bool, paths ...string)
- func MustShell(stackTrace bool, ctx context.Context, cmd string, args ...string) []byte
- func MustTempDir(stackTrace bool, dir, name string) string
- func MustUntar(stackTrace bool, dst string, r io.Reader, ...)
- func MustUntarFile(stackTrace bool, dst, src string, ...)
- func Shell(ctx context.Context, cmd string, args ...string) ([]byte, error)
- func Untar(dst string, r io.Reader, canOverwrite func(fn string, fi os.FileInfo) bool) error
- func UntarFile(dst, src string, canOverwrite func(fn string, fi os.FileInfo) bool) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CopyDir ¶
func CopyDir(dst, src string, canOverwrite func(fn string, fi os.FileInfo) bool) (files int, bytes int64, rerr error)
CopyDir recursively copies src to dest, preserving permissions and times where/when possible. If canOverwrite is not nil, it is consulted whether a destination file can be overwritten. If canOverwrite is nil then destination is overwritten if permissions allow that, otherwise the function fails.
Src and dst must be in the slash form.
func CopyFile ¶
func CopyFile(dst, src string, canOverwrite func(fn string, fi os.FileInfo) bool) (n int64, rerr error)
CopyFile copies src to dest, preserving permissions and times where/when possible. If canOverwrite is not nil, it is consulted whether a destination file can be overwritten. If canOverwrite is nil then destination is overwritten if permissions allow that, otherwise the function fails.
Src and dst must be in the slash form.
func Fatal ¶
func Fatal(stackTrace bool, args ...interface{})
Fatal prints its argumenst to os.Stderr and performs os.Exit(1). A stack trace is added if stackTrace is true.
func Fatalf ¶
Fatalf prints a formatted message to os.Stderr and performs os.Exit(1). A stack trace is added if stackTrace is true.
func MustAbsCwd ¶
MustAbsCwd is like AbsCwd but executes Fatal(stackTrace, err) if it fails.
func MustCopyDir ¶
func MustCopyDir(stackTrace bool, dst, src string, canOverwrite func(fn string, fi os.FileInfo) bool) (files int, bytes int64)
MustCopyDir is like CopyDir, but it executes Fatal(stackTrace, errú if it fails.
func MustCopyFile ¶
func MustCopyFile(stackTrace bool, dst, src string, canOverwrite func(fn string, fi os.FileInfo) bool) int64
MustCopyFile is like CopyFile but it executes Fatal(stackTrace, err) if it fails.
func MustMkdirs ¶
MustMkdirs is like Mkdir but if executes Fatal(stackTrace, err) if it fails.
func MustTempDir ¶
MustTempDir is like ioutil.TempDir but executes Fatal(stackTrace, err) if it fails. The returned path is absolute.
func MustUntar ¶
func MustUntar(stackTrace bool, dst string, r io.Reader, canOverwrite func(fn string, fi os.FileInfo) bool)
MustUntar is like Untar but it executes Fatal(stackTrace, err) if it fails.
func MustUntarFile ¶
func MustUntarFile(stackTrace bool, dst, src string, canOverwrite func(fn string, fi os.FileInfo) bool)
MustUntarFile is like UntarFile but it executes Fatal(stackTrace, err) if it fails.
func Shell ¶
Shell echoes and executes cmd with args and returns the combined output if the command. Passing nil is ok.
func Untar ¶
Untar extracts a tar.gz archive into dst. If canOverwrite is not nil, it is consulted whether a destination file can be overwritten. If canOverwrite is nil then destination is overwritten if permissions allow that, otherwise the function fails.
Dst must be in the slash form.
func UntarFile ¶
UntarFile extracts a named tar.gz archive into dst. If canOverwrite is not nil, it is consulted whether a destination file can be overwritten. If canOverwrite is nil then destination is overwritten if permissions allow that, otherwise the function fails.
Src and dst must be in the slash form.
Types ¶
This section is empty.