golang
已收录文章:1857篇
-
问题内容 我有以下嵌套结构,我想在模板中的{{range .Foos}}标签中迭代它们。 type Foo struct { Field1, Field2 string } type NestedStruct struct { NestedStructID string Foos []Foo } 我正在尝试使用以下 ht193 收藏
-
问题内容 我一直在尝试找到一种方法来优雅地停止 Go 中的侦听服务器。因为listen.Accept阻塞,有必要关闭侦听套接字以发出结束信号,但我无法将该错误与任何其他错误区分开来,因为相关497 收藏
-
问题内容 使用包https://github.com/golang/crypto/tree/master/ed25519我试图获取给定私钥的公钥。 这些数据来自http://www.bittorrent.org/beps/bep_0044.html:测试2(盐可变) 问题是,当我用给定的私钥喂它时162 收藏
-
问题内容 谁能告诉我为什么这不会编译? package main type myint int func set(a **myint) { i := myint(5) *a = &i } func main() { var k *int set( (**myint)(&k) ) // cannot convert &k (type **int) to type447 收藏
-
问题内容 我正在尝试读取加密的 PKCS8 私钥文件。我生成了这样的密钥: openssl genrsa -out file.pem -passout pass:file -aes256 1024 openssl pkcs8 -topk8 -inform pem -in file.pem -outform pem -out filePKCS8.pem 我尝试以490 收藏
-
问题内容 是否可以使用切片作为键? 我的尝试是: h := map[[]string]string{ []string{"a", "b"} : "ab", } 编译器给我一个错误invalid map key type []string。所以要么不可能,要么我110 收藏
-
问题内容 我正在尝试通过我的 Go 应用程序向 Twitter 发送请求,而 Twitter 的 API 要求您根据RFC 1738对使用者密钥和秘密进行编码。是否有内置的 Go 函数来执行此操作?从我在 net/url 包中看到118 收藏
-
问题内容 我有一个类似于这个的 JSON 对象: { "name": "Cain", "parents": { "mother" : "Eve", "father" : "Adam" } } 现在我想将“name”和“mot363 收藏
-
问题内容 I have written a small go program, and I want to generate standalone HTML documents from source code that can be viewed without godoc server. But I can't find any way to achieve it. if anyone could help me, I'll appreciate it. 正201 收藏
-
问题内容 可以使用以下简单的 go 代码片段重现该问题—— 简单的 go http 服务器: package main import ( "fmt" "log" "net/http" "time" ) func handler(w http.Response466 收藏
-
问题内容 我正在尝试使用 golang 将数据插入到 mysql 数据库中。在我的值采用空字符串的情况下,我想插入一个空值。如何调整以下内容以插入空值而不是空字符串?谢谢。 _, err := m.Db.Exec(`I280 收藏
-
问题内容 我希望在用 Go 编写的 webapp 中使用 MongoDB。 我可以拥有一个mgo.Session并在网络应用程序中同时使用它吗?例如在http.Handler 或者我应该打电话Session.Copy和Session.Close-> 建立会话池。130 收藏