1
0
mirror of https://github.com/strongdm/comply synced 2024-11-05 15:35:25 +00:00
comply/vendor/github.com/aktau/github-release/util.go

53 lines
893 B
Go
Raw Normal View History

2019-07-14 16:51:10 +00:00
package main
import (
"fmt"
"os"
"time"
)
/* oracle nvl, return first non-empty string */
func nvls(xs ...string) string {
for _, s := range xs {
if s != "" {
return s
}
}
return ""
}
func vprintln(a ...interface{}) (int, error) {
if VERBOSITY > 0 {
return fmt.Fprintln(os.Stderr, a...)
}
return 0, nil
}
func vprintf(format string, a ...interface{}) (int, error) {
if VERBOSITY > 0 {
return fmt.Fprintf(os.Stderr, format, a...)
}
return 0, nil
}
// formats time `t` as `fmt` if it is not nil, otherwise returns `def`
func timeFmtOr(t *time.Time, fmt, def string) string {
if t == nil {
return def
}
return t.Format(fmt)
}
// isCharDevice returns true if f is a character device (panics if f can't
// be stat'ed).
func isCharDevice(f *os.File) bool {
stat, err := f.Stat()
if err != nil {
panic(err)
}
return (stat.Mode() & os.ModeCharDevice) != 0
}