ccgo

package
v0.0.0-...-5c558cc Latest Latest
Warning

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

Go to latest
Published: Aug 9, 2024 License: BSD-3-Clause Imports: 14 Imported by: 0

Documentation

Overview

Package ccgo collects utilities often used while generating code with ccgo.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AbsCwd

func AbsCwd() (string, error)

AbsCwd returns the absolute working directory.

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 Env

func Env(key, dflt string) string

Env returns the value of environmental variable key of dflt otherwise.

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

func Fatalf(stackTrace bool, s string, args ...interface{})

Fatalf prints a formatted message to os.Stderr and performs os.Exit(1). A stack trace is added if stackTrace is true.

func InDir

func InDir(dir string, f func() error) (err error)

InDir executes f in dir. Dir must be in slash form.

func Mkdirs

func Mkdirs(paths ...string) error

Mkdirs will create all paths. Paths must be in slash form.

func MustAbsCwd

func MustAbsCwd(stackTrace bool) string

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 MustInDir

func MustInDir(stackTrace bool, dir string, f func() error)

MustInDir is like InDir but it executes Fatal(stackTrace, err) if it fails.

func MustMkdirs

func MustMkdirs(stackTrace bool, paths ...string)

MustMkdirs is like Mkdir but if executes Fatal(stackTrace, err) if it fails.

func MustShell

func MustShell(stackTrace bool, ctx context.Context, cmd string, args ...string) []byte

MustShell is like Shell but it executes Fatal(stackTrace, err) if it fails.

func MustTempDir

func MustTempDir(stackTrace bool, dir, name string) string

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

func Shell(ctx context.Context, cmd string, args ...string) ([]byte, error)

Shell echoes and executes cmd with args and returns the combined output if the command. Passing nil is ok.

func Untar

func Untar(dst string, r io.Reader, canOverwrite func(fn string, fi os.FileInfo) bool) error

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

func UntarFile(dst, src string, canOverwrite func(fn string, fi os.FileInfo) bool) error

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.

Jump to

Keyboard shortcuts

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