win golang下载
https://golang.google.cn/
项目结构
常用命令
go run
go build
go build -o test.exe
go install
交叉编译
go支持跨平台编译
例如:在windows平台编译一个能在linux平台执行的可执行文件
SET CGO_ENABLE=0 # 禁用CGO
SET GOOS=linux # 目标平台是linux
SET GOARCH=amd64 # 目标处理器是amd64
go build
25个关键字
break default func interface select
case defer go map struct
chan else goto package switch
const fallthrough if range type
continue for import return var
------------------------
重点
default interface select defer go
chan fallthrough
37个保留字
Constants: true false iota nil
Types: int int8 int16 int32 int64
uint uint8 uint16 uint32 uint64 uintptr
float32 float64 complex128 complex64
bool byte rune string error
Functions: make len cap new append copy close delete
complex real imag
panic recover
GO语言中的数据类型
https://www.liwenzhou.com/posts/Go/02_datatype/
常见问题
go的切片和python的切片有什么不同
https://blog.csdn.net/weixin_33730836/article/details/91905882
go语言中数组和切片的区别
https://segmentfault.com/a/1190000013148775
一个比较妙的题目,求最后的输出
考察点,
defer的调用顺序
defer函数执行和参数传值顺序
package main
import "fmt"
func calc(index string, a, b int) int {
ret := a + b
fmt.Println(index, a, b, ret)
return ret
}
func main() {
x := 1
y := 2
defer calc("AA", x, calc("A", x, y))
x = 10
defer calc("BB", x, calc("B", x, y))
y = 20
}
学习路径
https://www.liwenzhou.com/
https://www.bilibili.com/video/BV16E411H7og?p=4
看了学习Go语言这本书
里面讲的很简单
go的数据类型、函数、接口、并发、同步、io、网络。
其中,印象比较深刻的是defer、panic、recover,接口作为参数,goroutine,设置并行数量,chan int,select,网络io。