golang
已收录文章:13939篇
-
问题内容 我写了一个程序来演示 Go 中的浮点错误: func main() { a := float64(0.2) a += 0.1 a -= 0.3 var i int for i = 0; a < 1.0; i++ { a += a } fmt.Printf("After %d iterations, a = %e\362 收藏
-
问题内容 我有一段代码: //initialize a slice arr := make([]int, 0) arr = append(arr, 1, 2) for _, k := range arr { fmt.Printf("%p %+v\n", &k, k) } //make a copy, but the element is a pointer443 收藏
-
问题内容 package main import ( "encoding/json" "fmt" ) type PublicKey struct { name string price string } type KeysResponse struct { Collection []PublicKey } func main() { s := `[{"name":294 收藏
-
问题内容 我最近喜欢上了 Go 编程语言,到目前为止我觉得它很棒,但我真的很难理解接口。我已经阅读了很多关于它们的内容,但它们对我来说仍然很抽象。 我写了一些使用下面接口的快209 收藏
-
问题内容 我正在尝试通过执行以下操作使用 postgres 驱动程序(lib/pq)删除数据库: db.Exec("DROP DATABASE dbName;") 但是我想根据收到的错误是奇怪的东西还是“数据库不存在”错误来做278 收藏
-
问题内容 我有一个像这样的表驱动测试用例: func CountWords(s string) map[string]int func TestCountWords(t *testing.T) { var tests = []struct { input string want map[string]int }{ {"foo", map[string]int{&464 收藏