golang/go · warning

parse error

Error message

parse error

What it means

The deprecated -d flag on `go get` is a boolean flag whose Set calls strconv.ParseBool. If the supplied value cannot be parsed (ParseBool only accepts 1,t,T,TRUE,true,True,0,f,F,FALSE,false,False), Set returns "parse error" and flag parsing fails.

Source

Thrown at src/cmd/go/internal/modget/get.go:261

}

func (v *upgradeFlag) String() string { return "" }

// dFlag is a custom flag.Value for the deprecated -d flag
// which will be used to provide warnings or errors if -d
// is provided.
type dFlag struct {
	value bool
	set   bool
}

func (v *dFlag) IsBoolFlag() bool { return true }

func (v *dFlag) Set(s string) error {
	v.set = true
	value, err := strconv.ParseBool(s)
	if err != nil {
		err = errors.New("parse error")
	}
	v.value = value
	return err
}

func (b *dFlag) String() string { return "" }

func init() {
	work.AddBuildFlags(CmdGet, work.OmitModFlag)
	CmdGet.Run = runGet // break init loop
	CmdGet.Flag.Var(&getD, "d", "deprecated flag; is a no-op")
	CmdGet.Flag.Var(&getU, "u", "update modules providing dependencies to use newer minor or patch releases when available; -u=patch selects patch releases")
}

func runGet(ctx context.Context, cmd *base.Command, args []string) {
	moduleLoader := modload.NewLoader()
	switch getU.version {
	case "", "upgrade", "patch":

View on GitHub (pinned to b6b368adc5)

Solutions

  1. Drop the -d flag entirely; it is deprecated and a no-op in modern go.
  2. If you must set it, use a value strconv.ParseBool accepts: `-d=true` or `-d=false`.

Example fix

// before
//   go get -d=on example.com/foo
// after
//   go get example.com/foo      // -d removed (deprecated no-op)
Defensive patterns

Strategy: validation

Validate before calling

// Validate the flag value before passing it to `go get -d=`:
//   if _, err := strconv.ParseBool(v); err != nil {
//     // reject; or just drop the deprecated -d flag entirely
//   }

Prevention

When it happens

Trigger: Invoking `go get -d=<unparseable>` where the value is something like `-d=on`, `-d=yes`, or `-d=enable`.

Common situations: Scripts copy-pasted from documentation that used a non-bool; automation translating generic on/off flags to -d; misunderstanding the deprecated flag's accepted values.

Understand the failure class

Related errors


AI-assisted analysis of golang/go@b6b368adc5 (2026-08-12). Data as JSON: /api/errors/28fb75762713fce5. Report an issue: GitHub.