Gulu is a Golang util, gulu
inspired by 88250/gulu, cool!
go get -u github.com/elliotxx/gulu
func UnpackArchive(targetDir, archiveFile string) error
func UnpackTarGz(targetDir, archiveFile string) error
func UnpackZip(targetDir, archiveFile string) error
func CheckErr(err error)
Example:
func main() {
cmd := NewRootCommand()
if err := cmd.Execute(); err != nil {
cmdutil.CheckErr(err)
}
}
func FromConfigString(config, configType string, data interface{}) error
func FromFile(fs afero.Fs, filename string, data interface{}) error
func GetFileExtension(filename string) string
func IsValidConfigFilename(filename string) bool
Example:
configData := &Configuration{}
if !configutil.IsValidConfigFilename(configFile) {
return fmt.Errorf("invalid config file: %s", configFile)
}
err := configutil.FromFile(afero.NewOsFs(), configFile, configData)
if err != nil {
return err
}
func GetHeadHash() (sha string, err error)
func GetHeadHashShort() (sha string, err error)
func GetLatestTag() (string, error)
func GetLatestTagFromLocal() (tag string, err error)
func GetLatestTagFromRemote() (tag string, err error)
func GetRemoteURL() (string, error)
func GetTagCommitSha(tag string) (sha string, err error)
func GetTagCommitShaFromLocal(tag string) (sha string, err error)
func GetTagCommitShaFromRemote(_ string) (string, error)
func GetTagList() (tags []string, err error)
func GetTagListFromRemote(remoteURL string, reverse bool) (tags []string, err error)
func IsDirty() (dirty bool, err error)
func IsHeadAtTag(tag string) (bool, error)
func MustMarshal(v interface{}) []byte
func MustMarshalString(v interface{}) string
func MustPrettyMarshal(v interface{}) []byte
func MustPrettyMarshalString(v interface{}) string
func Debug(args ...interface{})
func Debugf(format string, args ...interface{})
func Error(args ...interface{})
func Errorf(format string, args ...interface{})
func Fatal(args ...interface{})
func Fatalf(format string, args ...interface{})
func Info(args ...interface{})
func Infof(format string, args ...interface{})
func Panic(args ...interface{})
func Panicf(format string, args ...interface{})
func SetLevel(level Level)
func SetLogger(config *Configuration)
func TimeEncoder(t time.Time, enc zapcore.PrimitiveArrayEncoder)
func Warn(args ...interface{})
func Warnf(format string, args ...interface{})
type Configuration
func NewDefaultConfiguration() *Configuration
type Level
func GetLevelFromStr(level string) Level
type LogFile
func GetLogFile() LogFile
type Logger
func GetKeys(m map[string]interface{}) []string
func Exists(path string) bool
func GetGoModRootDir(curDir string) (string, error)
func GetParentDir(dirctory string) string
func IsDir(path string) bool
func IsFile(path string) bool
func ReadLines(path string) ([]string, error)
func JSON() string
func ReleaseVersion() string
func ShortString() string
func String() string
func YAML() string
type BuildInfo
type GitInfo
type Info
func NewDefaultVersionInfo() *Info
func NewInfo() (*Info, error)
func NewMainOrDefaultVersionInfo() *Info
func (v *Info) JSON() string
func (v *Info) ShortString() string
func (v *Info) String() string
func (v *Info) YAML() string