diff options
Diffstat (limited to 'vendor/github.com/markbates/going/defaults/defaults.go')
-rw-r--r-- | vendor/github.com/markbates/going/defaults/defaults.go | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/vendor/github.com/markbates/going/defaults/defaults.go b/vendor/github.com/markbates/going/defaults/defaults.go new file mode 100644 index 0000000000..0d81de6f42 --- /dev/null +++ b/vendor/github.com/markbates/going/defaults/defaults.go @@ -0,0 +1,36 @@ +package defaults + +func String(s1, s2 string) string { + if s1 == "" { + return s2 + } + return s1 +} + +func Int(i1, i2 int) int { + if i1 == 0 { + return i2 + } + return i1 +} + +func Int64(i1, i2 int64) int64 { + if i1 == 0 { + return i2 + } + return i1 +} + +func Float32(i1, i2 float32) float32 { + if i1 == 0.0 { + return i2 + } + return i1 +} + +func Float64(i1, i2 float64) float64 { + if i1 == 0.0 { + return i2 + } + return i1 +} |