From e102a9ddf0dc978bae81f74a7d5e5025997f7fa1 Mon Sep 17 00:00:00 2001 From: Alfarih Faza Date: Mon, 3 Jan 2022 10:50:58 +0700 Subject: [PATCH] feat: added Get opt arg for int32 & int64 args --- args.go | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/args.go b/args.go index 3ad0bb8..8e7783d 100644 --- a/args.go +++ b/args.go @@ -26,6 +26,32 @@ func GetOptIntArg(opts []int, defaultValue ...int) int { return o } +func GetOptInt32Arg(opts []int32, defaultValue ...int32) int32 { + var o int32 = 0 + if len(defaultValue) > 0 { + o = defaultValue[0] + } + + if len(opts) > 0 { + o = opts[0] + } + + return o +} + +func GetOptInt64Arg(opts []int64, defaultValue ...int64) int64 { + var o int64 = 0 + if len(defaultValue) > 0 { + o = defaultValue[0] + } + + if len(opts) > 0 { + o = opts[0] + } + + return o +} + func GetOptBoolArg(opts []bool, defaultValue ...bool) bool { var o = false if len(defaultValue) > 0 {