golang/go · error

empty VCS name in GOVCS: %q

Error message

empty VCS name in GOVCS: %q

What it means

Within a GOVCS VCS list (the part after the colon, split by '|'), each individual VCS name must be non-empty. If splitting on '|' yields an empty element (e.g., trailing pipe, double pipe), the entry is rejected.

Source

Thrown at src/cmd/go/internal/vcs/vcs.go:662

		pattern, list = strings.TrimSpace(pattern), strings.TrimSpace(list)
		if pattern == "" {
			return nil, fmt.Errorf("empty pattern in GOVCS: %q", item)
		}
		if list == "" {
			return nil, fmt.Errorf("empty VCS list in GOVCS: %q", item)
		}
		if search.IsRelativePath(pattern) {
			return nil, fmt.Errorf("relative pattern not allowed in GOVCS: %q", pattern)
		}
		if old := have[pattern]; old != "" {
			return nil, fmt.Errorf("unreachable pattern in GOVCS: %q after %q", item, old)
		}
		have[pattern] = item
		allowed := strings.Split(list, "|")
		for i, a := range allowed {
			a = strings.TrimSpace(a)
			if a == "" {
				return nil, fmt.Errorf("empty VCS name in GOVCS: %q", item)
			}
			allowed[i] = a
		}
		cfg = append(cfg, govcsRule{pattern, allowed})
	}
	return cfg, nil
}

func (c *govcsConfig) allow(path string, private bool, vcs string) bool {
	for _, rule := range *c {
		match := false
		switch rule.pattern {
		case "private":
			match = private
		case "public":
			match = !private
		default:
			// Note: rule.pattern is known to be comma-free,

View on GitHub (pinned to b6b368adc5)

Solutions

  1. Ensure every pipe-separated VCS name is non-empty
  2. Format: `pattern:git|hg|fossil` with no trailing or doubled pipes
  3. Inspect the full GOVCS value for stray pipe characters

Example fix

# before: trailing pipe creates empty VCS name
export GOVCS="public:git|"

# after
export GOVCS="public:git"
Defensive patterns

Strategy: validation

Validate before calling

# Validate GOVCS VCS lists have no empty names (stray pipes)
GOVCS_VAL="${GOVCS:-}"
if [ -n "$GOVCS_VAL" ]; then
  echo "$GOVCS_VAL" | tr ',' '\n' | while IFS= read -r entry; do
    entry="$(echo "$entry" | xargs)"
    vcslist="${entry#*:}"
    echo "$vcslist" | tr '|' '\n' | while IFS= read -r vcs; do
      vcs="$(echo "$vcs" | xargs)"
      if [ -z "$vcs" ]; then
        echo "ERROR: empty VCS name in GOVCS entry: $entry (check for stray pipes)"
      fi
    done
  done
fi

Prevention

When it happens

Trigger: GOVCS VCS list contains an empty name: `GOVCS=public:git||hg` (double pipe) or `GOVCS=public:git|` (trailing pipe) or `GOVCS=public:|hg|` (leading/trailing pipe).

Common situations: Shell variable construction leaving stray pipes; copy-paste errors; incomplete editing of a VCS list.

Related errors


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