c2go-libcC runtime compatibility for the Go runtime environment
C input
#include <c2go.h>
c2go_extern int add(int a, int b) {
return a + b;
}
→Go call
import "example.com/demo/translated"
result := translated.Add(20, 22)
C2Go
A C-to-Go compiler toolchain, not a source rewriter
C2Go is a Clang-based ahead-of-time compilation mode for reusing or migrating existing C implementations as ordinary Go packages. It emits Plan 9 assembly for the Go assembler and a structured manifest, then c2go-bind generates a package the Go toolchain can build directly.
It does not promise to rewrite arbitrary C into hand-maintained Go source. C remains the implementation language while the compiled result uses goroutine stacks, Go scheduling, and an optional GC-aware memory model.
Build without cgo
Generated packages do not depend on import "C". c2go-libc uses a PureGo native-call bridge so consumers can build with CGO_ENABLED=0 and no host C compiler.
c2go-bind assembles the artifacts into a normal Go package.
mkdir -p translated
c2go-bind --out=translated --sidecar=.c2go/translated.json \
.c2go/translated.s
go test ./...
Current SDK platforms
Linuxamd64
Linuxarm64
Windowsamd64
macOSarm64
iRelease candidate; binaries are unsigned and APIs and ABI details may still change.
C2Go frequently asked questions
Does C2Go rewrite C as Go source?
It is not a general source-to-source rewriter. c2go-clang compiles C, and c2go-bind generates the .go and .s files that make up an ordinary Go package.
Does the final Go package require cgo?
No. Generation requires the C2Go SDK, but consumers can build with CGO_ENABLED=0 and without a host C compiler.
Which code and platforms are supported?
The current candidate targets C, not C++. Published SDKs cover Linux amd64/arm64, Windows amd64, and macOS arm64. Review the language, ABI, callback, and stack-pointer limits before adoption.
Is C2Go production-ready?
The current build is a pre-1.0 release candidate. Binaries are unsigned, and APIs and ABI details may change, so it is intended for evaluation, compatibility testing, and controlled migrations.
Start with Hello World
Begin with one C addition function, then learn GC-managed memory, interop, and multi-file builds.