golang
已收录文章:1803篇
-
问题内容 假设我主要是 Linux 用户,但我正在用 Go 开发一个我想成为跨平台的应用程序。我四处搜索,但似乎找不到信息来解决以下问题: 如果我go install在我的 amd64 Ubuntu 系统上使用二进226 收藏
-
问题内容 我以前从未将 golang 与 mysql 一起使用,所以我是第一次阅读这些内容。我想做这样的事情: if userId && gender && age db.QueryRow("SELECT name FROM users WHERE userId=? AND gender=? AND226 收藏
-
问题内容 例如,在这个答案中: https://stackoverflow.com/a/10385867/20654 ... if exiterr, ok := err.(*exec.ExitError); ok { ... err.(*exec.ExitError) 那叫什么?它是如何工作的? 正确答案 这是类型断言。我225 收藏
-
问题内容 在 Go 中进行日期比较有什么选择吗?我必须根据日期和时间对数据进行排序 - 独立。所以我可能允许一个对象出现在一个日期范围内,只要它也出现在一个时间范围内。在这个模225 收藏
-
问题内容 我正在使用 Go gin 框架gin func CORSMiddleware() gin.HandlerFunc { return func(c *gin.Context) { c.Writer.Header().Set("Content-Type", "application/json") c.Writer.Header().Set("Access-225 收藏
-
问题内容 我正在尝试解析 MySQL 错误,以便从 Go API 向用户返回干净的错误消息。 我读了一些类似[这篇](https://stackoverflow.com/questions/34008600/handle-a-specific- error-in-golang)文章,显示了我想做的225 收藏
-
问题内容 我注意到,如果我尝试在for循环中使用 goroutines 附加到切片,则会出现丢失/空白数据的情况: destSlice := make([]myClass, 0) var wg sync.WaitGroup for _, myObject := range sourceSlice { wg.Add(1)225 收藏
-
问题内容 我正在将一个库从 Ruby 移植到 Go,并且刚刚发现 Ruby 中的正则表达式与 Go (google RE2) 不兼容。我注意到 Ruby 和 Java(加上其他语言使用 PCRE 正则表达式(perl 兼容,支持捕获组))223 收藏
-
问题内容 我正在通过Go specification学习语言,这些要点取自Declarations and scope. 尽管我能够理解第 1-4 点,但我对以下几点感到5困惑6: 在函数内声明的常量或变量标识符的范围从 ConstSpec 或223 收藏
-
问题内容 In the gotour, there is a section: struct literals. package main import "fmt" type Vertex struct { X, Y int } var ( v1 = Vertex{1, 2} // has type Vertex v2 = Vertex{X: 1} // Y:0 is implicit v3 = Vertex{}223 收藏
-
问题内容 I have the following problem. I need to convert a structure to map[string]interface{} in order to perform an update in database (using mgo as driver for mongodb). Update For partially updating a document in mongoDB, the (optimal) soluti223 收藏
-
问题内容我正在尝试为将与文件系统交互的函数编写单元测试,并且我希望能够在测试期间模拟文件系统。[下面的代码是这个](https://stackoverflow.com/questions/16742331/how-to-mock-abstract-filesystem-i222 收藏