add func get value by key with binding

This commit is contained in:
Nam Huynh 2022-12-05 15:17:39 +07:00
parent 5d14b794dd
commit 93ee4df024
1 changed files with 3 additions and 3 deletions

View File

@ -16,11 +16,11 @@ func (s Server) GetValueByKey(ctx context.Context, key string) string {
return value return value
} }
// GetValueByKeyWithBinding ... // GetValueByKeyWithBindData ...
func (s Server) GetValueByKeyWithBinding(ctx context.Context, key string, result interface{}) error { func (s Server) GetValueByKeyWithBindData(ctx context.Context, key string, result interface{}) error {
v := s.GetValueByKey(ctx, key) v := s.GetValueByKey(ctx, key)
if v == "" { if v == "" {
return errors.New("key not found") return errors.New("key not found")
} }
return json.Unmarshal([]byte(v), result) return json.Unmarshal([]byte(v), &result)
} }