Die API-Referenz stammt aus den Go-Doc-Kommentaren im Quellcode und ist auf Englisch verfasst.
package godebug
import "github.com/nsgo-dev/game/pkg/tooling/godebug"Übersicht
Package godebug is experimental: its API and documented formats may change in a minor release. See the API stability policy. holds the pieces of running a game under the Go debugger: parsing Delve's listen announcement from nsgo dev -debug output and building the IDE attach configuration for it. Both game dev and the editor use it, so the configuration a CLI session prints and the one the editor copies or writes to .vscode/launch.json are the same.
Index
Konstanten
const AttachConfigName = "Attach to game"AttachConfigName is the name of the VS Code launch configuration, and the suggested GoLand Go Remote configuration, that attaches Delve to a running game.
Funktionen
func AttachConfig(host string, port int) attachConfigAttachConfig returns the attach configuration for the Delve server at host:port, named AttachConfigName. GoLand's equivalent is a Go Remote configuration with the same host and port.
func AttachConfigJSON(host string, port int) stringAttachConfigJSON returns AttachConfig as an indented JSON object, ready to paste into a .vscode/launch.json configurations array.
func ParseListenAddress(line string) (host string, port int, ok bool)ParseListenAddress extracts the host and port from Delve's listen announcement line. ok is false for any other line.
func UpsertVSCodeLaunchConfig(projectDir, host string, port int) errorUpsertVSCodeLaunchConfig writes the AttachConfigName configuration for the Delve server at host:port into projectDir/.vscode/launch.json, creating .vscode and the file when they are missing and replacing the entry of the same name when one is there. Other configurations and top-level members are preserved. A launch.json with comments or trailing commas (VS Code allows them) cannot be parsed and is reported as an error rather than rewritten.