// package decls, imports... type Setter interface { Set(string) } type Settable int // Set sets the value of *p from a string. func (p *Settable) Set(s string) { i, _ := strconv.Atoi(s) *p = Settable(i) } func FromStrings(type *T Setter)(s []string) []T { result := make([]T, len(s)) for i, v := range s { // result[i] is an addressable value of type T, // so it's OK to call Set. result[i].Set(v) } return result } func main() { nums := FromStrings(Settable)([]string{"1", "2", "3"}) fmt.Println(nums) }