Documentation ¶
Index ¶
- Constants
- Variables
- func AppLogger() *log.Entry
- func BackupGoModAndGoSum() (func(), error)
- func CheckErr(err error)
- func ConfigDir() (string, error)
- func CopyDirPreserve(src string, dst string) error
- func CopyFile(src, dst string) (err error)
- func DeleteDirContents(dir string) error
- func DeleteFile(fileName string) (err error)
- func DirExists(path string) (bool, error)
- func DownloadFile(filepath string, url string) (err error)
- func EnsureGoPath() error
- func FileExists(path string) (bool, error)
- func GetClientWithTimeout(duration time.Duration) *http.Client
- func GetModuleDir(moduleDir string, targetRequirement string, gopath string) (string, error)
- func GetModuleRequirements(dir string, gopath string) (map[string]map[string]string, error)
- func GoGet(path string, version string, gopath string, goModules bool, sourceOnly bool, ...) error
- func GoPath() string
- func GoPathBin(gopath string) string
- func GoPathMod(gopath string) string
- func GoPathSrc(gopath string) string
- func HomeDir() string
- func InvalidOptionf(option string, value interface{}, message string, a ...interface{}) error
- func IsolatedGoPath() (string, error)
- func JoinMap(m map[string]string, pairSep string, keyValueSep string) string
- func MissingOption(name string) error
- func SetLevel(s string) error
- type Command
- func (c *Command) Attempts() int
- func (c *Command) CurrentArgs() []string
- func (c *Command) CurrentDir() string
- func (c *Command) CurrentEnv() map[string]string
- func (c *Command) CurrentName() string
- func (c *Command) DidError() bool
- func (c *Command) DidFail() bool
- func (c *Command) Error() error
- func (c *Command) Run() (string, error)
- func (c *Command) RunWithoutRetry() (string, error)
- func (c *Command) SetArgs(args []string)
- func (c *Command) SetDir(dir string)
- func (c *Command) SetEnv(env map[string]string)
- func (c *Command) SetEnvVariable(name string, value string)
- func (c *Command) SetExponentialBackOff(backoff *backoff.ExponentialBackOff)
- func (c *Command) SetName(name string)
- func (c *Command) SetTimeout(timeout time.Duration)
- func (c *Command) String() string
- type CommandError
Constants ¶
const (
// AppName is tge application name for logging.
AppName = "codegen"
)
const (
// DefaultErrorExitCode is the default exit code in case of an error
DefaultErrorExitCode = 1
)
Variables ¶
var ( // ErrExit can be used to exit with a non 0 exit code without any error message ErrExit = fmt.Errorf("exit") )
Functions ¶
func BackupGoModAndGoSum ¶
func BackupGoModAndGoSum() (func(), error)
BackupGoModAndGoSum creates backup copies of go.mod and go.sum and returns a function to run at the end of execution to revert the go.mod and go.sum in the repo to the backups.
func CheckErr ¶
func CheckErr(err error)
CheckErr prints a user friendly error to STDERR and exits with a non-zero exit code.
func CopyDirPreserve ¶
CopyDirPreserve copies from the src dir to the dst dir if the file does NOT already exist in dst
func CopyFile ¶
CopyFile copies a file from the specified source src to dst. credit https://gist.github.com/r0l1/92462b38df26839a3ca324697c8cba04
func DeleteDirContents ¶
DeleteDirContents removes all the contents of the given directory
func DeleteFile ¶
DeleteFile deletes a file from the operating system. This should NOT be used to delete any sensitive information because it can easily be recovered. Use DestroyFile to delete sensitive information
func DownloadFile ¶
DownloadFile downloads a file from the given URL
func EnsureGoPath ¶
func EnsureGoPath() error
EnsureGoPath ensures the GOPATH environment variable is set and points to a valid directory.
func FileExists ¶
FileExists returns true if the specified path exist, false otherwise. An error is returned if and file system operation fails.
func GetClientWithTimeout ¶
GetClientWithTimeout returns a client with JX default transport and user specified timeout
func GetModuleDir ¶
GetModuleDir determines the directory on disk of the specified module dependency. Returns the empty string if the target requirement is not part of the module graph.
func GetModuleRequirements ¶
GetModuleRequirements returns the requirements for the GO module rooted in dir It returns a map[<module name>]map[<requirement name>]<requirement version>
func GoGet ¶
func GoGet(path string, version string, gopath string, goModules bool, sourceOnly bool, update bool) error
GoGet runs go get to install the specified binary.
func GoPath ¶
func GoPath() string
GoPath returns the first element of the GOPATH. The empty string is returned if GOPATH is not set.
func InvalidOptionf ¶
InvalidOptionf returns an error that shows the invalid option.
func IsolatedGoPath ¶
IsolatedGoPath returns the isolated go path for codegen
func MissingOption ¶
MissingOption reports a missing command line option using the full name expression.
Types ¶
type Command ¶
type Command struct { Errors []error Dir string Name string Args []string ExponentialBackOff *backoff.ExponentialBackOff Timeout time.Duration Out io.Writer Err io.Writer Env map[string]string // contains filtered or unexported fields }
Command is a struct containing the details of an external command to be executed
func (*Command) CurrentArgs ¶
CurrentArgs returns the current command arguments
func (*Command) CurrentDir ¶
CurrentDir returns the current Dir
func (*Command) CurrentEnv ¶
CurrentEnv returns the current environment variables
func (*Command) CurrentName ¶
CurrentName returns the current name of the command
func (*Command) DidError ¶
DidError returns a boolean if any error occurred in any execution of the command
func (*Command) DidFail ¶
DidFail returns a boolean if the command could not complete (errored on every attempt)
func (*Command) RunWithoutRetry ¶
RunWithoutRetry Execute the command without retrying on failure and block waiting for return values
func (*Command) SetArgs ¶
SetArgs Setter method for Args to enable use of interface instead of Command struct
func (*Command) SetDir ¶
SetDir Setter method for Dir to enable use of interface instead of Command struct
func (*Command) SetEnv ¶
SetEnv Setter method for Env to enable use of interface instead of Command struct
func (*Command) SetEnvVariable ¶
SetEnvVariable sets an environment variable into the environment
func (*Command) SetExponentialBackOff ¶
func (c *Command) SetExponentialBackOff(backoff *backoff.ExponentialBackOff)
SetExponentialBackOff Setter method for ExponentialBackOff to enable use of interface instead of Command struct
func (*Command) SetName ¶
SetName Setter method for Name to enable use of interface instead of Command struct
func (*Command) SetTimeout ¶
SetTimeout Setter method for Timeout to enable use of interface instead of Command struct
type CommandError ¶
type CommandError struct { Command Command Output string // contains filtered or unexported fields }
CommandError is the error object encapsulating an error from a Command
func (CommandError) Error ¶
func (c CommandError) Error() string