I have an array of structs.
var a = [] struct {
f1 string
f2 string
}{
{"foo", "bar"},
{"biz", "baz"},
}
I want to pass an array of the f2 fields to a function, like so
var f2s []string
for _, s := range a {
f2s = append.f2s(s.f2)
}
// f2s = {"bar", "baz"}
SomeFunc(f2s)
Is there a more idiomatic way to do this? In Python I would do SomeFunc([s.f2 for s in a]). In a functional language I would do (SomeFunc (map (lambda (s) (s.f2)) a)).