随笔分类 - golang
摘要:先在服务器上安装go-delve go-delve的github地址:https://github.com/go-delve 在服务器上安装好go语言的环境,然后在服务器上安装go-delve go install github.com/go-delve/delve/cmd/dlv@latest 以
阅读全文
摘要:package main import ( "fmt" "reflect" "time" ) type TA struct { Id *int32 `json:"id"` TT TT `json:"tt"` Arr Array[int32] `json:"arr"` Date Datetime `j
阅读全文
摘要:go语言的错误处理没有其他语言的try,catch,finally异常捕获机制,需要显式地进行错误处理,如果只是单纯地将错误返回,在深度过大时可能无法清楚地知道调用的链路。这时候可以通过自定义错误类型,包装错误(wrap error)进行处理,在发生错误时返回带上调用链路。 package main
阅读全文
摘要:package main import ( "fmt" "gorm.io/gorm" ) var GDB *gorm.DB type T struct { Id int32 `json:"id"` Pid int32 `json:"pid" gorm:"index"` Name string `js
阅读全文
摘要:go中Struct转map,map转Struct的测试 package main import ( "fmt" "github.com/mitchellh/mapstructure" "reflect" "time" ) func main() { type Info struct { Addr s
阅读全文