// 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
Deprecated string `json:",omitempty"`
}
+type debugJSON struct {
+ Key string
+ Value string
+}
+
type requireJSON struct {
Path string
Version string `json:",omitempty"`
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)
--- /dev/null
+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
+}