![](https://img-blog.csdnimg.cn/20201014180756926.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
Golang
golang demo & notes
Jay_hj11
这个作者很懒,什么都没留下…
展开
-
Golang Test files tips
Golang Test UnitTest Coverage BDD原创 2022-04-04 00:31:35 · 292 阅读 · 0 评论 -
go array和slice的区别 golang面试题 002
002 go array和slice的区别相同点都是属于集合类的类型,用来存储同一种类型的数据或者元素不同点数组的长度固定,数组是值类型(值类型有基本数据类型,结构体类型),数组的空余位置用0填补,不允许数组越界。slice的值长度可变,属于引用类型(引用类型:字典类型,通道类型,函数类型)切片是引用传递,所以它们不需要使用额外的内存并且比使用数组更有效率。如果传递的是引用类型,那么就是“传引用”,如果传递的是值类型,那么就是“传值”(会把以前的数据复制一遍)数组长度在声明的时候就必须给定,原创 2021-11-23 09:37:30 · 378 阅读 · 0 评论 -
golang面试题 001
001 go channel close后读的问题golang channel关闭后,其中剩余的数据,是可以继续读取的。请看下面的测试例子。创建一个带有缓冲的channel,向channel中发送数据,然后关闭channel,最后,从channel中读取数据,输出结果。package mainimport "fmt"//go channel close后读的问题func main() { ch := make(chan string, 3) ch <- "test1" ch原创 2021-11-22 23:59:28 · 6458 阅读 · 0 评论 -
golang map
https://zhuanlan.zhihu.com/p/27108356https://zhuanlan.zhihu.com/p/364904972https://zhuanlan.zhihu.com/p/273666774https://zhuanlan.zhihu.com/p/157465066https://zhuanlan.zhihu.com/p/102385081原创 2021-11-21 23:33:17 · 172 阅读 · 0 评论 -
golang slice
Go 语言切片(Slice)Go 语言切片是对数组的抽象。Go 数组的长度不可改变,在特定场景中这样的集合就不太适用,Go 中提供了一种灵活,功能强悍的内置类型切片(“动态数组”),与数组相比切片的长度是不固定的,可以追加元素,在追加时可能使切片的容量增大。slice的基本信息可以从下面这个link看到slice 菜鸟编程Go Slice探秘——slice作为函数参数传递时,若修改函数中的slice,到底会不会改变原slice的值?Anaswer空(nil)切片一个切片在未初始化之前默认为原创 2021-11-19 16:22:51 · 73 阅读 · 0 评论 -
Golang VScode debug设置
尝试vscode debug ,但是遇到下面错误DAP server listening at: 127.0.0.1:62253Build Error: go build -o C:\GoProject\kb-api-gateway\src\__debug_bin.exe -gcflags all=-N -l .\server.gogo: gopkg.in/guregu/null.v4@v4.0.0: missing go.sum entry; to add it: go mod download原创 2021-11-18 09:41:10 · 1484 阅读 · 0 评论 -
Golang VS Code 中的代码自动补全和自动导入包
Golang VS Code 中的代码自动补全和自动导入包VSCode 必须安装以下插件:首先你必须安装 Golang 插件,然后再给 Go 安装工具包。在 VS Code 中,使用快捷键:command(windows ctrl)+shift+P,然后键入:go:install/update tools,将所有 16 个插件都勾选上,然后点击 OK 即开始安装。Installing 16 tools at /Users/maiyang/develop/goworkspace//bingoc原创 2021-01-20 01:15:11 · 5066 阅读 · 0 评论 -
Custom JSON Marshalling&UnMarshalling in Go
We know that through tags, we can conditionally customize the way of Go JSON serialization, such as json:",omitempty".We know that through tags, we can conditionally customize the way of Go JSON serialization, such as json:",omitempty". When the value of原创 2021-11-17 10:31:18 · 101 阅读 · 0 评论 -
parsing time “\“\““ as “\“2006-01-02T15:04:05Z07:00\““: cannot parse “\““ as “2006“
I encounter the below error when I want to parse such string to struct.parsing time “”"" as ““2006-01-02T15:04:05Z07:00"”: cannot parse “”” as "2006"package mainimport ( "fmt" "time" "encoding/json")func main() { s :=`[ {"name":"test1","expireA原创 2021-11-17 11:36:34 · 4604 阅读 · 0 评论