Safeguard
Developer Tools•

What does GOVCS do in Go and should you change it?

GOVCS limits which version control tools the go command runs to fetch modules. Learn the syntax, the default, and when to tighten it for safety.

Safeguard Security Team
3 min read

GOVCS tells the go command which version control systems it may run for which module paths. The default allows git and hg for public modules and any tool for private ones. Tightening it to git only, or turning it off for a pattern, reduces what your build machines will execute when fetching code.

Why it exists

When the go command fetches a module directly from a repository, it runs a tool such as git. Version control tools are large programs with a history of their own security fixes, and they process data from servers you do not control. GOVCS, introduced in Go 1.16, lets you decide which ones are acceptable.

Syntax

From the Go modules reference, GOVCS is a comma separated list of rules in the form pattern:vcslist:

  • Patterns are glob patterns matched against leading path elements.
  • The vcslist is pipe separated, or all, or off.
  • The earliest matching pattern applies.
  • Special patterns public and private are also supported.
  • The default is equivalent to public:git|hg,private:all.

Example:

GOVCS=github.com:git,evil.com:off,*:git|hg

Other forms: GOVCS=*:all allows everything, and GOVCS=*:off disables version control downloads. GOPRIVATE also determines whether a module counts as private for this setting.

Choosing a setting

SettingEffectGood for
Defaultgit and hg for public, anything for privateMost teams
public:git,private:gitOnly git, everywhereLocked down build agents
Specific host offNo VCS fetch from that hostBlocking a known bad source
*:offNo direct VCS downloadsBuilds that must use a proxy or vendor directory only

Steps to tighten safely

  1. Check which hosts your modules come from. Most teams use only git hosting.
  2. Set GOVCS on CI agents to allow only git, for example public:git,private:git.
  3. Run a clean build with an empty cache. Anything that needed another tool will fail loudly.
  4. For a fully proxied setup, combine with a module proxy so public modules arrive over HTTPS, not through VCS commands.
  5. Document the setting next to your GOPRIVATE configuration. See GOPRIVATE, GONOPROXY and GONOSUMDB.

What it does not do

GOVCS does not check module contents. Hashes in go.sum and the checksum database do that. It narrows the tools involved in fetching, which is a smaller attack surface, not a content guarantee.

Where Safeguard fits

Safeguard's dependency scanning and policy gates cover what lands in your module graph, and a free scan shows the current state of a repository.

Quick check

What is the GOVCS default?

Equivalent to public:git|hg,private:all, per the Go modules reference.

Which rule wins if two patterns match?

The earliest matching pattern in the list applies.

Sources

Last reviewed: 19 October 2026.

Never miss an update

Weekly insights on software supply chain security, delivered to your inbox.

Self-healing security runs on Safeguard.

Your first fix PR is minutes away.

No sales call required, even your agent can complete the purchase over MCP.