+2
Daily
5,825
stars
391
forks
39
watchers
838
prs
461
issues
28
releases
README
garble go install mvdan.cc/garble@latest or @master Obfuscate Go code by wrapping the Go toolchain. Requires Go 1.27 or later. garble build [build flags] [packages] The tool also supports garble test to run tests with obfuscated code, garble run to obfuscate and execute simple programs, garble reverse to de-obfuscate text such as stack traces, and garble bug to file a pre-filled bug report. Run garble -h to see all available commands and flags. Purpose Produce a binary that works as well as a regular build, but that has as little information about the original source code as possible. The tool is designed to be: Coupled with cmd/go, to support modules and build caching Deterministic and reproducible, given the same initial source code Reversible given the original source, to de-obfuscate panic stack traces Mechanism The tool wraps calls to the Go compiler and linker to transform the Go build, in order to: Replace identifiers and package paths with short base64 hashes Replace position information with short base64 hashed filenames Remove all build, module, and debug information Obfuscate literals and embedded files, if the -literals flag is given Remove extra information, if the -tiny flag is given The tool obfuscates all packages being built, including the standard runtime. Runtime obfuscation follows Go's supported GOOS/GOARCH targets; Garble does not maintain a narrower architecture allowlist. Note that commands like garble build will use the go version found in your $PATH. To use different versions of Go, you can use GOTOOLCHAIN. Use cases A common question is why a code obfuscator is needed for Go, a compiled language. Go binaries include a surprising amount of information about the original source; even with debug information and symbol tables stripped, many names and positions remain in place for the sake of traces, reflection, and debugging. Some use cases for Go require sharing a Go binary with the end user. If the source code for the binary is private or requires a purchase, its obfuscation can help discourage reverse engineering. A similar use case is a Go library whose source is private or purchased. Since Go libraries cannot be imported in binary form, and Go plugins have their shortcomings, sharing obfuscated source code becomes an option. See 369. Obfuscation can also help with aspects entirely unrelated to licensing. For example, the -tiny flag can make binaries 15% smaller, similar to the common practice in Android to reduce app sizes. Obfuscation has also helped some open source developers work around anti-virus scans incorrectly treating Go binaries as malware. Word-list naming Use garble -wordlist=words.txt build to replace identifier, package-path, and filename hashes with underscore-separated combinations of words. The file contains one lowercase ASCII word per line, at most eight letters per word. Blank lines and surrounding whitespace are ignored. The list is sorted and deduplicated, s
Top issues
#462consider ways to better obfuscate function bodies36 comments · 2022-01-16#369add an "export" command for libraries25 comments · 2021-06-21#810Potential pull request for gomobile support20 comments · 2023-11-18#866hello world and anything detected by global check (virustotal)18 comments · 2024-08-16#87Support Go plugins14 comments · 2020-08-09#218include extra context in compiler and linker errors7 comments · 2021-02-03#572"filename or extension is too long" when building many source files6 comments · 2022-08-26#298add support for "garble list"?5 comments · 2021-04-05
Discussions
#1040Question: current maturity and production-readiness of control flow obfuscation1 comments · 2026-05-23#983ungarbler protection1 comments · 2025-12-09#931Obfuscation and Go templates1 comments · 2025-03-17#917[Question] Will Magic Value Lead To Identification?1 comments · 2025-02-21#863How to get reverse to work on main package/methods?0 comments · 2024-07-23#852Environnement variable0 comments · 2024-05-16#826Generate transformation mapping?1 comments · 2024-01-11#796Error when attempting to build in yocto2 comments · 2023-09-21
Latest release
v0.18.0 v0.18.0 2026-09-19This release adds support for Go 1.27 and drops support for Go 1.26. Builds are now 10% to 15% faster, depending on the size of the build and the number of spare CPU cores, as the patched linker is now built in the background while packages are listed rather than right before linking. Experimental control flow obfuscation via //garble:controlflow is now reproducible for a given -seed, and handles many more Go constructs: bound method values, generic conversions, types declared in block scopes, named map and string types, blank struct fields, and comma-ok receives in select. Ranging over