2021-01-17 21:46:25 +08:00
|
|
|
// Copyright GoFrame Author(https://goframe.org). All Rights Reserved.
|
2020-05-04 23:42:51 +08:00
|
|
|
//
|
|
|
|
|
// This Source Code Form is subject to the terms of the MIT License.
|
|
|
|
|
// If a copy of the MIT was not distributed with this file,
|
|
|
|
|
// You can obtain one at https://github.com/gogf/gf.
|
|
|
|
|
|
|
|
|
|
package gvar
|
|
|
|
|
|
2020-06-15 16:46:48 +08:00
|
|
|
import (
|
2021-10-11 21:41:56 +08:00
|
|
|
"github.com/gogf/gf/v2/util/gconv"
|
2020-06-15 16:46:48 +08:00
|
|
|
)
|
2020-05-04 23:42:51 +08:00
|
|
|
|
2021-08-16 21:47:45 +08:00
|
|
|
// Struct maps value of `v` to `pointer`.
|
|
|
|
|
// The parameter `pointer` should be a pointer to a struct instance.
|
|
|
|
|
// The parameter `mapping` is used to specify the key-to-attribute mapping rules.
|
2020-06-29 13:40:19 +08:00
|
|
|
func (v *Var) Struct(pointer interface{}, mapping ...map[string]string) error {
|
2020-05-04 23:42:51 +08:00
|
|
|
return gconv.Struct(v.Val(), pointer, mapping...)
|
|
|
|
|
}
|
|
|
|
|
|
2021-08-16 21:47:45 +08:00
|
|
|
// Structs converts and returns `v` as given struct slice.
|
2020-06-29 13:40:19 +08:00
|
|
|
func (v *Var) Structs(pointer interface{}, mapping ...map[string]string) error {
|
2020-05-04 23:42:51 +08:00
|
|
|
return gconv.Structs(v.Val(), pointer, mapping...)
|
|
|
|
|
}
|