Abstract
Come for a deep dive into the Go toolchain, including how "go build" runs the compiler and linker, and how all of it can be leveraged to write advanced tools like a code obfuscator. Go has a great ecosystem for tooling. Not only is the language fairly simple, but there are also excellent libraries to parse, type-check, and manipulate code. Thanks to the above, many tools exist out there, from linters to dependency analyzers and editor integrations. However, there's a space that hasn't been explored much so far - modifying Go builds, in particular by hooking straight into the "go build" command and its components, such as the compiler and linker. We'll dive deep into how the Go toolchain works, what pieces are the most interesting, and what kind of tools could be built with them. Finally, we will walk through a real use case; obfuscating Go code. Thanks to the legwork in the previous section, we'll quickly show how to obfuscate Go code straight from "go build" without a custom pre-process step.