garble -literals build exec ./main$exe cmp stderr main.stderr ! binsubstr main$exe 'Lorem' 'ipsum' 'dolor' 'first assign' 'second assign' 'First Line' 'Second Line' 'map value' 'to obfuscate' 'also obfuscate' binsubstr main$exe 'Skip this block,' 'also skip this' [short] stop # checking that the build is reproducible is slow # Also check that the binary is reproducible. cp main$exe main_old$exe rm main$exe garble -literals build bincmp main$exe main_old$exe -- go.mod -- module test/main -- main.go -- package main type strucTest struct { field string anotherfield string } const ( cnst = "Lorem" multiline = `First Line Second Line` ) const ( skip1 = "Skip this block," i = 1 ) const ( foo = iota bar skip2 = "also skip this" ) const arrayLen = 4 var array [arrayLen]byte type typeAlias [arrayLen]byte func main() { empty := "" localVar := "dolor" reassign := "first assign" reassign = "second assign" println(cnst) println(multiline) println(variable) println(localVar) println(reassign) println(empty) x := strucTest{ field: "to obfuscate", anotherfield: "also obfuscate", } println(x.field) println(x.anotherfield) testMap := map[string]string{"map key": "map value"} println(testMap["map key"]) println("another literal") println(skip1, skip2) println(i, foo, bar) } -- decl_without_imports.go -- package main // The lack of imports is an edge case, since we have to add imports like // crypto/aes. var variable = "ipsum" -- main.stderr -- Lorem First Line Second Line ipsum dolor second assign to obfuscate also obfuscate map value another literal Skip this block, also skip this 1 0 1