diff options
| author | Ian Alexander <jitsu@google.com> | 2025-09-25 11:07:17 -0400 |
|---|---|---|
| committer | Ian Alexander <jitsu@google.com> | 2025-11-08 04:25:35 -0800 |
| commit | b76103c08e72ac34db2092d2cf1a3c1ec6adf451 (patch) | |
| tree | 066178748c53188385132c976705a0819d38e9aa /src/cmd | |
| parent | 47a63a331daa96de55562fbe0fa0201757c7d155 (diff) | |
| download | go-b76103c08e72ac34db2092d2cf1a3c1ec6adf451.tar.xz | |
cmd/go: output missing GoDebug entries
The `go help mod edit` command references the GoDebug struct, but `go
mod edit -json` was not displaying them when appropriate.
Fixes #75105
Change-Id: Iec987882941e01b0cf4d4fe31dda9e7a6e2dde87
Reviewed-on: https://go-review.googlesource.com/c/go/+/706757
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Michael Matloob <matloob@google.com>
Reviewed-by: Michael Matloob <matloob@golang.org>
Diffstat (limited to 'src/cmd')
| -rw-r--r-- | src/cmd/go/internal/modcmd/edit.go | 13 | ||||
| -rw-r--r-- | src/cmd/go/testdata/script/mod_edit_issue75105.txt | 36 |
2 files changed, 47 insertions, 2 deletions
diff --git a/src/cmd/go/internal/modcmd/edit.go b/src/cmd/go/internal/modcmd/edit.go index 4cd8d87501..69ebb14813 100644 --- a/src/cmd/go/internal/modcmd/edit.go +++ b/src/cmd/go/internal/modcmd/edit.go @@ -584,8 +584,9 @@ func flagDropIgnore(arg string) { // fileJSON is the -json output data structure. type fileJSON struct { Module editModuleJSON - Go string `json:",omitempty"` - Toolchain string `json:",omitempty"` + Go string `json:",omitempty"` + Toolchain string `json:",omitempty"` + GoDebug []debugJSON `json:",omitempty"` Require []requireJSON Exclude []module.Version Replace []replaceJSON @@ -599,6 +600,11 @@ type editModuleJSON struct { Deprecated string `json:",omitempty"` } +type debugJSON struct { + Key string + Value string +} + type requireJSON struct { Path string Version string `json:",omitempty"` @@ -657,6 +663,9 @@ func editPrintJSON(modFile *modfile.File) { for _, i := range modFile.Ignore { f.Ignore = append(f.Ignore, ignoreJSON{i.Path}) } + for _, d := range modFile.Godebug { + f.GoDebug = append(f.GoDebug, debugJSON{d.Key, d.Value}) + } data, err := json.MarshalIndent(&f, "", "\t") if err != nil { base.Fatalf("go: internal error: %v", err) diff --git a/src/cmd/go/testdata/script/mod_edit_issue75105.txt b/src/cmd/go/testdata/script/mod_edit_issue75105.txt new file mode 100644 index 0000000000..8984daee25 --- /dev/null +++ b/src/cmd/go/testdata/script/mod_edit_issue75105.txt @@ -0,0 +1,36 @@ +env GO111MODULE=on + +go mod edit -godebug 'http2debug=2' +cmp go.mod go.mod.edit.want1 + +go mod edit -json +cmp stdout go.mod.edit.want2 +-- go.mod -- +module foo + +go 1.25.0 +-- go.mod.edit.want1 -- +module foo + +go 1.25.0 + +godebug http2debug=2 +-- go.mod.edit.want2 -- +{ + "Module": { + "Path": "foo" + }, + "Go": "1.25.0", + "GoDebug": [ + { + "Key": "http2debug", + "Value": "2" + } + ], + "Require": null, + "Exclude": null, + "Replace": null, + "Retract": null, + "Tool": null, + "Ignore": null +} |
