golang
已收录文章:1857篇
-
问题内容 My instinct tells me that somehow it would have to be converted to a string or byte[] (which might even be the same things in Go?) and then saved to disk. I found this package (http://golang.org/pkg/encoding/gob/), but it seems like its293 收藏
-
问题内容 我有以下代码: func sendRegularHeartbeats(ctx context.Context) { for { select { case <-ctx.Done(): return case <-time.After(1 * time.Second): sendHeartbeat() }204 收藏
-
问题内容 我正在使用vscode扩展Go来编辑golang源代码。每次我想格式化代码时,我都必须按Ctrl-Shift-ion linux、Shift-Alt-FonWindows或Ctrl- Shift-p然后键入format。是否可以在保存时设置格式,也就是说368 收藏
-
问题内容 用一些错误消息中止我的 API服务的方法是什么? 调用我的服务的链接: http://creative.test.spoti.io/api/getVastPlayer?add= {"Json":Json}&host=api0.spoti.io&domain=domain&userAgent=user238 收藏
-
问题内容 我有最基本的 net/http 程序,用于学习 Go 中的命名空间: package main import ( "fmt" "log" "net/http" ) func main() { http.HandleFunc("/", func(w http.ResponseW466 收藏
-
问题内容 I have this code where I just want to set a environment variable: package main import ( "os" "fmt" ) func main() { _ = os.Setenv("FOO", "BAR") fmt.Println(os.Getenv("FOO&quo322 收藏
-
问题内容 这是我的代码,我不明白为什么解码功能不起作用。 请稍有洞察力会很棒。 func EncodeB64(message string) (retour string) { base64Text := make([]byte, base64.StdEncoding.EncodedLen(len(message))) base64101 收藏
-
问题内容 如果我有: type foo struct{ } func bar(baz interface{}) { } 以上是一成不变的——我不能改变 foo 或 bar。此外,baz 必须转换回 bar 内的 foo 结构指针。如何将 &foo{} 转换为 interfa127 收藏
-
问题内容 我正在尝试将以下代码从 IndexedDB JavaScript API 转换为 GO WASM: request.onupgradeneeded = function(event) { var result = event.target.result; var objectStore = result.createObjectStore("employee", {keyP245 收藏
-
问题内容 一个人怎么能只尝试在 go 中获取一个类似互斥锁的锁,或者立即中止(就像 TryLock 在其他实现中所做的那样),或者通过观察某种形式的截止日期(基本上 是 LockBefore )? 我现158 收藏
-
问题内容 给定以下代码: package main import ( "fmt" "math/rand" "time" ) func main() { for i := 0; i < 3; i++ { go f(i) } // prevent main from exiting immediately var344 收藏
-
问题内容 Is it possible to create a wrapper for arbitrary function in Go that would take the same arguments and return the same value? I'm not talking about the wrapper that would look exactly the same, it may look differently, but it should sol341 收藏