Go 语言笔试面试题
日常收集的题
一. 基础语法
1 = 和 := 的区别?...编译时,会按照前一行的定义自动补全。...var y int = M
7 fmt.Println(x, y)
8}
答案
编译失败:cannot use M (type int32) as type int in assignment
Go 语言中...2
3import "fmt"
4
5func main() {
6 a := []int{0, 1, 2, 3, 4, 5, 6, 7, 8, 9}
7 b := a[2:5]
8 c...:= a[9:10]
9 b = append(b, 1)
10 c = append(c, 1)
11 fmt.Println(a)
12}
答案
[0 1 2 3 4 1 6 7 8 9]