golang/go · error

marshal embedcfg: %v

Error message

marshal embedcfg: %v

What it means

Thrown during the Go build when the toolchain JSON-encodes the embed configuration (the resolved //go:embed patterns and files) that gets passed to the compiler. The marshaled struct holds only map[string][]string and map[string]string fields, both always JSON-safe, so this is a defensive check for an effectively-impossible internal condition. Reaching it signals a corrupted toolchain or memory fault rather than a user mistake.

Source

Thrown at src/cmd/go/internal/work/exec.go:832

		fmt.Fprintf(&icfg, "packagefile %s=%s\n", p1.ImportPath, a1.built)
	}

	// Prepare Go embed config if needed.
	// Unlike the import config, it's okay for the embed config to be empty.
	var embedcfg []byte
	if len(p.Internal.Embed) > 0 {
		var embed struct {
			Patterns map[string][]string
			Files    map[string]string
		}
		embed.Patterns = p.Internal.Embed
		embed.Files = make(map[string]string)
		for _, file := range p.EmbedFiles {
			embed.Files[file] = fsys.Actual(filepath.Join(p.Dir, file))
		}
		js, err := json.MarshalIndent(&embed, "", "\t")
		if err != nil {
			return fmt.Errorf("marshal embedcfg: %v", err)
		}
		embedcfg = js
	}

	// Find PGO profile if needed.
	var pgoProfile string
	for _, a1 := range a.Deps {
		if a1.Mode != "preprocess PGO profile" {
			continue
		}
		if pgoProfile != "" {
			return fmt.Errorf("action contains multiple PGO profile dependencies")
		}
		pgoProfile = a1.built
	}

	var coverageConfig string
	if coverPr != nil {

View on GitHub (pinned to b6b368adc5)

Solutions

  1. Reinstall or upgrade the Go toolchain to rule out a corrupted binary
  2. Run `go env` and confirm a standard GOROOT/GOTOOLCHAIN
  3. Report a bug to the Go project with the full build log and the package's //go:embed directives if reproducible
Defensive patterns

Strategy: validation

Prevention

When it happens

Trigger: Fires in (b *Builder).build at the json.MarshalIndent(&embed,...) call, only when a package has //go:embed directives (len(p.Internal.Embed) > 0) and the marshal of the embed{Patterns,Files} struct returns a non-nil error.

Common situations: A corrupted or forked go binary, memory corruption, or an exotic toolchain modification. Not reachable through normal //go:embed usage, since the data types involved are always serializable.

Related errors


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