From 29ce595d208c1cf543732c5ddfd1bfff6ee36441 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E5=85=89=E6=98=A5?= Date: Tue, 30 Aug 2022 09:43:06 +0800 Subject: [PATCH] - add get --- const.go | 2 +- get.go | 15 +++++++++++++++ 2 files changed, 16 insertions(+), 1 deletion(-) create mode 100644 get.go diff --git a/const.go b/const.go index bde248b..4bdefb1 100644 --- a/const.go +++ b/const.go @@ -1,3 +1,3 @@ package gostring -const Version = "1.0.9" +const Version = "1.0.10" diff --git a/get.go b/get.go new file mode 100644 index 0000000..4f96625 --- /dev/null +++ b/get.go @@ -0,0 +1,15 @@ +package gostring + +func GetDefault(key, defVal any) any { + if key != nil { + return key + } + return defVal +} + +func GetStringDefault(key, defVal string) string { + if key != "" { + return key + } + return defVal +}