Skip to content
| Marketplace
Sign in
Visual Studio Code>Programming Languages>CGONew to Visual Studio Code? Get it now.
CGO

CGO

Arcmantle

|
1 install
| (1) | Free
C tooling for cgo preambles in Go files.
Installation
Launch VS Code Quick Open (Ctrl+P), paste the following command, and press enter.
Copied to clipboard
More Info

CGO

CGO brings C-aware tooling to cgo preambles inside Go files.

Build VSIX

It detects import "C" preambles, mirrors them into generated C translation units, and delegates language features such as hover and document symbols to your installed C tooling. The result is a more usable editing experience for projects that embed C, system headers, or platform interop code directly inside Go source.

Why CGO

Most editors treat cgo preambles as opaque comments. CGO turns them into something your C tooling can understand without forcing generated files into your repository.

Features

  • Semantic highlighting for cgo preambles embedded in Go files.
  • Accurate preamble detection using a Go backend that understands real Go syntax.
  • Generated mirror C files stored outside the workspace so repositories stay clean.
  • Hover and document symbol delegation to installed C tooling such as clangd.
  • Command to open the extracted C mirror for direct inspection.
  • Windows-specific compile metadata generation so system headers resolve correctly in mirrored files.
  • Bundled backend binaries for windows-amd64, linux-amd64, linux-arm64, and darwin-arm64.

Quick Start

  1. Install CGO.
  2. Make sure a C language provider such as clangd is installed in VS Code.
  3. Open a Go file that contains an import "C" preamble.
  4. Run CGO: Open Extracted C if you want to inspect the generated mirror file directly.

How It Works

When CGO finds a cgo preamble, it extracts the C content into a generated mirror file and uses that file as the bridge to existing C language tooling. This allows VS Code to provide C-oriented insight for code that lives inside a Go comment block.

Backend resolution order:

  1. cgo.backendPath if explicitly configured.
  2. Bundled backend binary for the current OS and architecture.
  3. go run ./cmd/cgo-backend when running from a source checkout.

Requirements

  • VS Code 1.98.0 or newer.
  • A C language provider if you want delegated language features such as hover and symbols. clangd is the expected choice.
  • Go is not required for normal VSIX installs, but it is useful for source checkout development.

What You Get

  • Better visibility into cgo preambles without moving code out of the Go file.
  • Reuse of mature C tooling instead of a custom parser for every editor feature.
  • A clean workspace because generated mirror files live outside the repository.

Commands

  • CGO: Open Extracted C
  • CGO: Show Detected Blocks

Settings

  • cgo.backendPath: absolute path to a backend executable override.
  • cgo.goExecutable: Go executable to use for source-checkout fallback execution.

Limitations

  • Inline diagnostics and completions are not yet delegated back into the Go cgo block itself.
  • Raw #cgo directives are blanked in mirror files so the generated C remains valid for language tooling.
  • Delegated hover and symbols depend on a working C language provider installation.

Development

pnpm install
pnpm build

Useful scripts:

  • pnpm build: builds the current-platform backend and the extension.
  • pnpm run build:backend:matrix: builds the packaged backend matrix in parallel.
  • pnpm run package:vsix: builds the matrix, compiles the extension, and creates a VSIX.

License

CGO is source-available.

  • Personal use is allowed.
  • Internal organizational use is allowed, including internal commercial use.
  • Internal modification and internal copying for installation or backup are allowed.
  • Redistribution, resale, sublicensing, bundling, hosted/OEM use, and publishing modified versions for third parties require prior written permission.

See LICENSE.txt for the full license terms.

CI and Releases

  • Pushes to main, pull requests, and manual workflow runs build a VSIX in GitHub Actions.
  • Tagged releases matching v* attach the generated VSIX to the GitHub release automatically.
  • Workflow artifacts can be downloaded from the Actions tab for test installs.

Repository

  • Source: https://github.com/arcmantle/vscode-cgo
  • Issues: https://github.com/arcmantle/vscode-cgo/issues
  • Contact us
  • Jobs
  • Privacy
  • Manage cookies
  • Terms of use
  • Trademarks
© 2026 Microsoft