How does the Go1 compiler work?

The Go compiler is written in pure C and does not use the packages under go/. In the Go source tree, its lexer lives in src/cmd/gc/lex.c and its Bison grammar is src/cmd/gc/go.y.

The go/ packages are used in tools like godoc, gofmt, and various go tool subcommands. Maybe someday they can be used to write a Go compiler in Go as well, but no one’s gotten very far on that path yet.

Leave a Comment