Anti-AIClone

Log date · Wed

Do Go struct tags survive stripping?

Yes. Our stripped Go build retained field tags and a sample string, despite a smaller binary and a missing symbol match.

Do Go field tags survive stripping?

Yes. In our Go 1.26.2 sample, both a normal build and one built with -trimpath and -s -w retained two JSON field tags and a sample string; both produced the same output. The stripped build fell from 2,964,640 to 1,973,328 bytes, but that did not conceal those values.

Results of our comparison
QuestionFinding
Size after stripping?1,973,328 bytes versus 2,964,640 normally.
The tags and sample string?Exact byte matches in both binaries.
The main.main symbol?A match in the normal build, none in the stripped build.
Runtime behavior?Both print the same JSON and tags.

GoReSym v3.4 makes this question timely. Released on 2026-07-01 at 20:29 UTC, it added struct field tag recovery (PR #97) and a starting virtual address for recovered Go strings (PR #100), both contributed by @kami922. [1]

How we compared the builds

We wrote a Plan struct with two JSON tags. The program serializes the struct and then reads its tags through reflection. GoReSym was unavailable here, so this uses the Go toolchain to illustrate the metadata issue; it is not a test of v3.4. The sample ran on darwin/amd64, and its results describe this program and toolchain.

The struct in our own sample.
type Plan struct {
    Price int `json:"demo_internal_price"`
    Flag string `json:"demo_feature_flag"`
}

The normal variant uses default build settings; the other combines path trimming and linker options. Go documents -s as omitting the symbol table and debug information and implying -w; -trimpath replaces filesystem paths with module or import paths. [3][4] These options do not promise to remove every type detail the program needs at runtime.

The two build commands used in the experiment.
go build -o normal main.go
go build -trimpath -ldflags='-s -w' -o stripped main.go

Tags and symbols are different evidence

Filtering go tool nm for main.main produced a match in the normal binary and none in the stripped binary. At the same time, an exact byte search found both tags and DEMO-PLAN in each file. This is the contiguous output for the stripped variant.

Copied verbatim from the transcript.
== stripped behavior ==
{"demo_internal_price":120,"demo_feature_flag":"DEMO-PLAN"}
tags: demo_internal_price demo_feature_flag
== stripped exact bytes ==
demo_internal_price: present
demo_feature_flag: present
DEMO-PLAN: present
== stripped main.main symbol ==

The reflect API represents StructTag as a field’s tag string, and Get retrieves the value for a key. [5] Here the program reads the tags itself and also uses them to produce JSON, so the tags have a clear runtime purpose. An exact byte search answers only whether those known bytes occur; a missing match does not establish that the artifact contains no other readable information.

The GoReSym README describes extracting function, file and type metadata from Go programs, including special handling for stripped binaries. [2] The address added in v3.4 is a way to locate a string; it does not automatically explain the business rule that uses it. Tags and names are structural clues, but can disclose the meaning of an interface or configuration.

Recommendations by case

These are engineering recommendations, not protection gains measured by our experiment. Decide what disclosure of a name or value would cost before changing an interface.

Recommendations by content
QuestionFinding
Public JSON fieldKeep the contract stable; do not break compatibility merely to hide a name.
Unpublished pricing or feature ruleConsider server-side evaluation where connectivity permits; inspect responses too.
Shared privileged credentialRemove it from the client and rotate any value already shipped.
Fields used by reflection or serializationRetest compatibility and data migration after renaming or obfuscation.

Offline functionality still has to execute on the device. Moving sensitive logic to a server can add latency and change the offline experience. Where migration is impossible, assume the client can be inspected and design permissions, data value and updates together. A smaller binary is not a confidentiality metric.

From this result to a release review

This comparison changes path handling and linker options together, so the size difference cannot be attributed separately to either one. Both programs print the same result, but that verifies only this execution path. A real application also needs coverage for reading old data, error handling and any plugin or reflection calls. Keep each build configuration with its inspection results so you can compare again after upgrading Go or changing dependencies.

Inspection output can itself contain internal names. Store the report where your team controls access and record the location, impact and owner of each finding; copying the entire binary into the report is unnecessary. Treat public fields that must remain as versioned interfaces.

Check your own Go release

Build an artifact with your actual release configuration for an internal review, and record the Go version, build identifier and target platform. Replace the path and example tag below with your own values and inspect files you are authorized to review. go version -m can show embedded build information. [4]

Substitute your artifact and a known test tag; matching output can contain other binary data.
go version
go version -m path/to/your-app
go tool nm path/to/your-app | grep 'main.main'
grep -aF 'your_known_test_tag' path/to/your-app

Do not paste real credentials into commands, logs or reports. No match can also reflect a tool, encoding or layout limitation; record tool errors and combine the check with reflection and serialization tests and an artifact review. After changing build or obfuscation settings, retest critical paths, release signing and notarization where applicable, then repeat the inspection on the new final artifact.

Your checklist

  • Record the Go version, platform and build identifier for the release.
  • Inspect known field tags, strings and embedded build information.
  • Remove shared privileged credentials from the client and rotate them.
  • Retest reflection and serialization after renaming or obfuscation.
  • Recheck the signed final artifact and notarization where applicable.

Primary sources

All sources and reproduction status ↗