there are two questions here:
* how to transform the data the way you want
* how to do it idiomatically in go
Patrick's answer is correct, but it's worth going a bit more deeply into the real difference: go does have anonymous inline functions - which is basically what Ruby's blocks are - but since it's a strongly typed language, function composition will never look as clean as it does in Ruby.
Your ruby code is functionally equivalent to this Go code:
func map(f func(s string) string, coll []string) []string {
var newColl = make([]string, len(coll)
for i, s := coll {
newColl[i] = f(s)
}
}
map(strings.TrimSpace, strings.Split(string(line, "\t)))
But that's generally not idiomatic in go: since the map() function must be typed, it's usually more concise just to do everything inline like Patrick showed. In programs where you're doing a lot of transformations between the same two types it can be worthwhile to write a mapper, but in practise most go code will look more or less like C for operations like this.