增加读取数据并解析成制定数据结构的方法
This commit is contained in:
parent
e6dbb4026a
commit
0d9fa31401
28
middleware/apollo/extend.go
Normal file
28
middleware/apollo/extend.go
Normal file
@ -0,0 +1,28 @@
|
||||
// Package apollo...
|
||||
//
|
||||
// Description : 扩展第三方库的一些函数
|
||||
//
|
||||
// Author : go_developer@163.com<白茶清欢>
|
||||
//
|
||||
// Date : 2021-11-24 10:16 下午
|
||||
package apollo
|
||||
|
||||
import (
|
||||
"git.zhangdeman.cn/zhangdeman/gopkg/util"
|
||||
"github.com/pkg/errors"
|
||||
)
|
||||
|
||||
// GetValueWithReceiver 读取数据,并解析到指定的数据结构中
|
||||
//
|
||||
// Author : go_developer@163.com<白茶清欢>
|
||||
//
|
||||
// Date : 10:18 下午 2021/11/24
|
||||
func GetValueWithReceiver(key string, receiver interface{}) error {
|
||||
var (
|
||||
result string
|
||||
)
|
||||
if result = Client.GetStringValue(key, ""); len(result) == 0 {
|
||||
return errors.New("key is not found : " + key)
|
||||
}
|
||||
return util.JSONUnmarshalWithNumber([]byte(result), receiver)
|
||||
}
|
Loading…
Reference in New Issue
Block a user