diff options
author | Máximo Cuadros <mcuadros@gmail.com> | 2017-04-06 22:32:08 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-04-06 22:32:08 +0200 |
commit | c34356d70ec011b8fe3a18bd60ce8234541358f7 (patch) | |
tree | 091972513babd4beca29d0318058facb678e5d1c /_examples/common.go | |
parent | 8ede7794a674fd890147f81201e25ecb517046f0 (diff) | |
parent | e0b296d0d0d235ad848cce7bc19130505c33d97b (diff) | |
download | go-git-c34356d70ec011b8fe3a18bd60ce8234541358f7.tar.gz |
Merge pull request #331 from marwan-at-work/examples
add git checkout example + housekeeping
Diffstat (limited to '_examples/common.go')
-rw-r--r-- | _examples/common.go | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/_examples/common.go b/_examples/common.go index 913cb18..2719c0e 100644 --- a/_examples/common.go +++ b/_examples/common.go @@ -6,6 +6,8 @@ import ( "strings" ) +// CheckArgs should be used to esnure the right command line arguments are +// passed before executing an example. func CheckArgs(arg ...string) { if len(os.Args) < len(arg)+1 { Warning("Usage: %s %s", os.Args[0], strings.Join(arg, " ")) @@ -13,6 +15,7 @@ func CheckArgs(arg ...string) { } } +// CheckIfError should be used to naively panics if an error is not nil. func CheckIfError(err error) { if err == nil { return @@ -22,10 +25,12 @@ func CheckIfError(err error) { os.Exit(1) } +// Info should be used to describe the example commands that are about to run. func Info(format string, args ...interface{}) { fmt.Printf("\x1b[34;1m%s\x1b[0m\n", fmt.Sprintf(format, args...)) } +// Warning should be used to display a warning func Warning(format string, args ...interface{}) { fmt.Printf("\x1b[36;1m%s\x1b[0m\n", fmt.Sprintf(format, args...)) } |