Go 坑
justinsun221
这个作者很懒,什么都没留下…
展开
-
GO坑
1.简短声明的变量只能在函数内部使用// 错误示例myvar := 1 // syntax error: non-declaration statement outside function bodyfunc main() {}// 正确示例var myvar = 1func main() {}2.Array 类型的值作为函数参数在 C/C++ 中,数组(名)是指针。将数组作为参数传进函数时,相当于传递了数组内存地址的引用,在函数内部会改变该数组的值。在 Go 中,数组是转载 2020-08-25 11:36:46 · 182 阅读 · 0 评论 -
Golang 的 “omitempty” 关键字略解
原文载于 https://old-panda.com/2019/12/11/golang-omitempty/用法熟悉 Golang 的朋友对于 json 和 struct 之间的转换一定不陌生,为了将代码中的结构体与 json 数据解耦,通常我们会在结构体的 field 类型后加上解释说明,例如在表示一个地址的时候, json 数据如下所示{ "street": "200 Larkin St", "city": "San Francisco", "state": "CA",转载 2020-08-12 15:34:31 · 1121 阅读 · 0 评论 -
安装go package 利器
作者踩了好多坑,最后终于找到一个办法解决golang.org package 安装In Linux or macOS, you can execute the below commands.Enable the go modules featureexport GO111MODULE=on# Set the GOPROXY environment variableexport GOPR...原创 2020-01-10 10:44:06 · 235 阅读 · 0 评论