这有效:
type T string
var t T = "hello"
http://play.golang.org/p/275jQ4ixvp
但这失败了 cannot use s (type string) as type T in assignment
s := "world"
var t T = s
http://play.golang.org/p/vm3mC5ltcE
我怎样才能使第二种情况起作用?
相关分类