github.com/m4gshm/gollections@v0.0.13-0.20240331203319-a34a86e58a24/internal/examples/mapexamples/map_Convert_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_Convert(t *testing.T) { 12 13 var employers = map[string]map[string]string{ 14 "devops": {"name": "Bob"}, 15 "jun": {"name": "Tom"}, 16 } 17 18 var all = map_.Convert(employers, func(title string, employer map[string]string) (string, string) { 19 return string([]rune(title)[0]), employer["name"] 20 }) 21 //map[d:Bob j:Tom] 22 23 assert.Equal(t, map[string]string{"d": "Bob", "j": "Tom"}, all) 24 25 }