```
package main
import "log"
//S .
type S map[string]string
//SS .
type SS = map[string]string
func main() {
s := map[string]string{
"1": "111",
"2": "222",
}
log.Printf("s type:%T,value:%#v\n", s, s)
var ss S
ss = s
log.Printf("ss type:%T,value:%#v\n", ss, ss)
var sss SS
sss = s
log.Printf("sss type:%T,value:%#v\n", sss, sss)
}
```
运行结果:
```
$ go run .
2020/10/10 13:42:24 s type:map[string]string,value:map[string]string{"1":"111", "2":"222"}
2020/10/10 13:42:24 ss type:main.S,value:main.S{"1":"111", "2":"222"}
2020/10/10 13:42:24 sss type:map[string]string,value:map[string]string{"1":"111", "2":"222"}
```
为什么ss = s这条语句可以赋值成功,类型定义不是新的类型吗?
有疑问加站长微信联系(非本文作者)