问题
- https://programnotes.cn/golang-1000-question/
- code,repo in github <git@github.com:yiGmMk/golang-1000-question.git>
- 代码允许环境:
- go version go1.15.3 linux/amd64
const
[001]iota,有常量如下,second数值是?
1
2
3
4
5
6const (
first = 1
second =iota
third
fourth
)- 答: 1
- 参考:
- go官方文档: https://golang.google.cn/pkg/builtin/#iota
- go by example: https://golangbyexample.com/iota-in-golang/
string
[002]strings.ReplaceAll,代码如下,replace的值是?
1
2
3
4origin := " 特斯拉Model X "
replace := strings.ReplaceAll(origin, " ", "")
fmt.Printf("origin:%s\nreplace:%s\n", origin, replace)答: “ 特斯拉Model X “,即origin