Actually, after a quick examination of the Go libraries, I'm not sure I can agree that it's "idiomatic Go". I still see many things that strike me as "artifacts of the C conversion" more than "the way someone would have written this from scratch".
The careful package split is something to be copied, though.
Re:Writing a Compiler in Go
by iso-8859-1 on Tuesday May 03, 2016 @10:48AM
(#11621140)
The conversion from C to Go was done in 2014, so it is surprising that it is not complete yet.
See "Go, From C to Go by Russ Cox" (with video) at https://github.com/gophercon/2014-talks
it is complete, but it's a conversion, not a rewrite. i doubt anyone will spend the time to rewrite the compiler in idiomatic Go soon. bigger fish to fry :)
Re:Writing a Compiler in Go
by stcredzero on Tuesday May 03, 2016 @02:01PM
(#11622855)
Where is a good place to read "idiomatic Go?"
Much of the rest of the standard library. The compiler portion is a special case.
The standard library.
>I would like to mention that most, if not all, of the Go compiler and related utilities is written in Go itself, with high quality, open source code
High quality? Isn't the compiler since 1.5 auto-generated from C for the most part, and quite crap with regards to optimizations/readability?
https://golang.org/pkg/go/
I would recommend using that as a template for one's own compiler, because it's written in idiomatic Go (originally by the language creators) and is cleanly split across abstraction boundaries (packages "scanner", "parser", "ast", and so on.)
There's also a smaller, simpler parser in the "text/template/parse" package, that is used to parse the templating languages in "text/template" and "html/template". As an introduction to it, I recommend the talk "Lexical Scanning in Go" by Rob Pike:
https://www.youtube.com/watch?v=HxaD_trXwRE