GitHubНачать

Справочник API собран из Go doc-комментариев в исходном коде и написан на английском языке.

package godebug

import "github.com/nsgo-dev/game/pkg/tooling/godebug"

Обзор

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.

Указатель

Константы

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.

Функции

func AttachConfig(host string, port int) attachConfig

AttachConfig 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) string

AttachConfigJSON 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) error

UpsertVSCodeLaunchConfig 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.