We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
主要记录在面试中遇到的试题
A:defer 压入方法栈中,先进后出,return 返回值在所有 defer 执行完成后执行
package main import "fmt" func run() int{ defer (func() { fmt.Println(1) })() defer (func() { fmt.Println(2) })() defer (func() { fmt.Println(3) })() return 4 } func main() { fmt.Println(run()) }
3 2 1 4
A:
参考内容:
A:这个涉及到版本会有所不同,最终的内存分配都会想上修正
参考内容
package main import "fmt" func main() { s := make([]int, 5) s = append(s, 1, 2, 3) fmt.Println(s) }
A: 切片中会默认存放当前类型的默认值,在其后方追加内容。
[0 0 0 0 0 1 2 3]
The text was updated successfully, but these errors were encountered:
No branches or pull requests
前言
主要记录在面试中遇到的试题
程序调度
Q1. 多个 defer() 和 return 的执行顺序
A:defer 压入方法栈中,先进后出,return 返回值在所有 defer 执行完成后执行
字符串
Q1. ',",` 有什么区别
A:
参考内容:
切片
Q1: 切片的扩容因子是多少?
A:这个涉及到版本会有所不同,最终的内存分配都会想上修正
参考内容
Q2: 下方代码的打印结果如何?
A: 切片中会默认存放当前类型的默认值,在其后方追加内容。
The text was updated successfully, but these errors were encountered: