# Past garble versions might not properly patch cmd/link with "git apply" # when running inside a git repository. Skip the extra check with -short. [!short] [exec:git] exec git init -q [!short] [exec:git] env GARBLE_CACHE_DIR=$WORK/linker-cache garble build exec ./main ! cmp stderr main.stderr [short] stop # no need to verify this with -short go build exec ./main cmp stderr main.stderr -- go.mod -- module test/main go 1.19 -- main.go -- package main import ( "strconv" "strings" _ "unsafe" ) type fakeModuleData struct { pcHeader *struct { magic uint32 } } //go:linkname activeModules runtime.activeModules func activeModules() []*fakeModuleData // genericMagicValue returns magic value without last digit func genericMagicValue() string { mod := activeModules()[0] magicValHex := strings.ToUpper(strconv.FormatUint(uint64(mod.pcHeader.magic), 16)) return "0x" + magicValHex[:len(magicValHex)-1] + "?" } func main() { println(genericMagicValue()) } -- main.stderr -- 0xFFFFFFF?