gvar_struct.go 840 B

1234567891011121314151617181920212223
  1. // Copyright GoFrame Author(https://goframe.org). All Rights Reserved.
  2. //
  3. // This Source Code Form is subject to the terms of the MIT License.
  4. // If a copy of the MIT was not distributed with this file,
  5. // You can obtain one at https://github.com/gogf/gf.
  6. package gvar
  7. import (
  8. "github.com/gogf/gf/v2/util/gconv"
  9. )
  10. // Struct maps value of `v` to `pointer`.
  11. // The parameter `pointer` should be a pointer to a struct instance.
  12. // The parameter `mapping` is used to specify the key-to-attribute mapping rules.
  13. func (v *Var) Struct(pointer interface{}, mapping ...map[string]string) error {
  14. return gconv.Struct(v.Val(), pointer, mapping...)
  15. }
  16. // Structs converts and returns `v` as given struct slice.
  17. func (v *Var) Structs(pointer interface{}, mapping ...map[string]string) error {
  18. return gconv.Structs(v.Val(), pointer, mapping...)
  19. }