github.com/wangyougui/gf/v2@v2.6.5/container/gvar/gvar_list.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/wangyougui/gf. 6 7 package gvar 8 9 import ( 10 "github.com/wangyougui/gf/v2/util/gutil" 11 ) 12 13 // ListItemValues retrieves and returns the elements of all item struct/map with key `key`. 14 // Note that the parameter `list` should be type of slice which contains elements of map or struct, 15 // or else it returns an empty slice. 16 func (v *Var) ListItemValues(key interface{}) (values []interface{}) { 17 return gutil.ListItemValues(v.Val(), key) 18 } 19 20 // ListItemValuesUnique retrieves and returns the unique elements of all struct/map with key `key`. 21 // Note that the parameter `list` should be type of slice which contains elements of map or struct, 22 // or else it returns an empty slice. 23 func (v *Var) ListItemValuesUnique(key string) []interface{} { 24 return gutil.ListItemValuesUnique(v.Val(), key) 25 }