I was just wondering why the string functions in Google Go are defined in a strings
package as opposed to on the string
data type itself. They could have easily done
func (s string) ToUpper() string {
}
instead of the current
func ToUpper(s string) string {
}
in the strings
package.
My guess is that if you want to implement a custom version of ToUpper
on a custom type that extends string
(i.e., type MyString string
), you have no way to access the builtin ToUpper
anymore on that type, but I can't find any support on this.