From 59aeb88808ed8d0722d20febf13def5739c8aaee Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=99=BD=E8=8C=B6=E6=B8=85=E6=AC=A2?= Date: Thu, 21 Nov 2024 15:16:30 +0800 Subject: [PATCH] =?UTF-8?q?map=20=E5=A2=9E=E5=8A=A0=E8=8E=B7=E5=8F=96?= =?UTF-8?q?=E5=AD=97=E7=AC=A6=E4=B8=B2=E7=BB=93=E6=9E=9C=E6=96=B9=E6=B3=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- map.go | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/map.go b/map.go index 0df970a..084695d 100644 --- a/map.go +++ b/map.go @@ -234,3 +234,19 @@ func (m Map) ToString() string { byteData, _ := m.MarshalJSON() return string(byteData) } + +// GetString 获取字符串结果 +// +// 参数说明: +// - field : 要查找的字段 +// +// Author : go_developer@163.com<白茶清欢> +// +// Date : 15:15 2024/11/21 +func (m Map) GetString(field string) (string, error) { + val, err := m.Get(field) + if nil != err { + return "", err + } + return AnyDataType(val).ToString().Value(), nil +}