golang/go · error

importcfg:%d: invalid importmap: syntax is "importmap old=ne

Error message

importcfg:%d: invalid importmap: syntax is "importmap old=new": %s

What it means

The gccgo importcfg parser handles `importmap old=new` directives. Both sides of the '=' must be non-empty after strings.Cut. If either is empty, this fires with the line number and offending line. Same validation shape as 1196 but for import-remapping directives used to alias import paths.

Source

Thrown at src/cmd/go/internal/work/gccgo.go:178

		}
		before, after, _ := strings.Cut(args, "=")
		switch verb {
		default:
			base.Fatalf("importcfg:%d: unknown directive %q", lineNum, verb)
		case "packagefile":
			if before == "" || after == "" {
				return fmt.Errorf(`importcfg:%d: invalid packagefile: syntax is "packagefile path=filename": %s`, lineNum, line)
			}
			archive := gccgoArchive(root, before)
			if err := sh.Mkdir(filepath.Dir(archive)); err != nil {
				return err
			}
			if err := sh.Symlink(after, archive); err != nil {
				return err
			}
		case "importmap":
			if before == "" || after == "" {
				return fmt.Errorf(`importcfg:%d: invalid importmap: syntax is "importmap old=new": %s`, lineNum, line)
			}
			beforeA := gccgoArchive(root, before)
			afterA := gccgoArchive(root, after)
			if err := sh.Mkdir(filepath.Dir(beforeA)); err != nil {
				return err
			}
			if err := sh.Mkdir(filepath.Dir(afterA)); err != nil {
				return err
			}
			if err := sh.Symlink(afterA, beforeA); err != nil {
				return err
			}
		case "packageshlib":
			return fmt.Errorf("gccgo -importcfg does not support shared libraries")
		}
	}
	return nil
}

View on GitHub (pinned to b6b368adc5)

Solutions

  1. Do not hand-edit importcfg files; let the go command generate them
  2. Rebuild from scratch: `go clean -cache && go build`
  3. Confirm a compatible gccgo/go version
Defensive patterns

Strategy: validation

Validate before calling

// Validate an importcfg importmap line before passing it to gccgo
func validImportmapLine(line string) bool {
    _, after, ok := strings.Cut(line, " ")
    if !ok { return false }
    before, after, ok := strings.Cut(after, "=")
    return ok && before != "" && after != ""
}

Prevention

When it happens

Trigger: Fires in the gccgo importcfg reader's `case "importmap"` branch when before == "" or after == "" after strings.Cut(args, "=").

Common situations: A corrupted or hand-edited importcfg file, or a toolchain bug emitting a malformed importmap line.

Related errors


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