github.com/m4gshm/gollections@v0.0.13-0.20240331203319-a34a86e58a24/internal/examples/mapexamples/map_ConvertValues_test.go (about) 1 package mapexamples 2 3 import ( 4 "testing" 5 6 "github.com/stretchr/testify/assert" 7 8 "github.com/m4gshm/gollections/map_" 9 ) 10 11 func Test_ConvertValues(t *testing.T) { 12 13 var employers = map[string]map[string]string{ 14 "devops": {"name": "Bob"}, 15 "jun": {"name": "Tom"}, 16 } 17 18 var vals = map_.ConvertValues(employers, func(employer map[string]string) string { 19 return employer["name"] 20 }) 21 //map[devops:Bob jun:Tom] 22 23 assert.Equal(t, map[string]string{"devops": "Bob", "jun": "Tom"}, vals) 24 }