github.com/gogf/gf/v2@v2.7.4/container/gvar/gvar_struct.go (about)

     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  
     7  package gvar
     8  
     9  import (
    10  	"github.com/gogf/gf/v2/util/gconv"
    11  )
    12  
    13  // Struct maps value of `v` to `pointer`.
    14  // The parameter `pointer` should be a pointer to a struct instance.
    15  // The parameter `mapping` is used to specify the key-to-attribute mapping rules.
    16  func (v *Var) Struct(pointer interface{}, mapping ...map[string]string) error {
    17  	return gconv.Struct(v.Val(), pointer, mapping...)
    18  }
    19  
    20  // Structs converts and returns `v` as given struct slice.
    21  func (v *Var) Structs(pointer interface{}, mapping ...map[string]string) error {
    22  	return gconv.Structs(v.Val(), pointer, mapping...)
    23  }