在这个奇怪的示例中,有人创建了一个实际上只是一个字符串的新类型:
type CustomType string
const (
Foobar CustomType = "somestring"
)
func SomeFunction() string {
return Foobar
}
但是,此代码无法编译:
不能将Foobar(CustomType类型)用作返回参数中的类型字符串
如何修复SomeFunction,使其能够返回Foobar("omestring")的字符串值?