ToString() function in Go
问题 The strings.Join function takes slices of strings only: s := []string{"foo", "bar", "baz"} fmt.Println(strings.Join(s, ", ")) But it would be nice to be able to pass arbitrary objects which implement a ToString() function. type ToStringConverter interface { ToString() string } Is there something like this in Go or do I have to decorate existing types like int with ToString methods and write a wrapper around strings.Join ? func Join(a []ToStringConverter, sep string) string 回答1: Attach a