Repository navigation
gen: drop -trimpath set in the go env file - #11
Merged
Merged
Conversation
The loader removed -trimpath only from a GOFLAGS environment variable. A -trimpath set with go env -w still applied, so a model field whose type has constants in a package outside the patterns failed: its position named the module path instead of the file on disk. The loader now reads the effective GOFLAGS from go env and writes it back without -trimpath and with -trimpath=false, since an empty GOFLAGS reads as unset and brings the file back. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What changes
keel gennow reads the effectiveGOFLAGSfromgo env, which honors both the environment and the go env file. It passes that value to the package loader without-trimpathand with-trimpath=false.Why
The loader dropped
-trimpathonly from aGOFLAGSenvironment variable. A-trimpathset withgo env -w GOFLAGS=-trimpathstill applied. A model field whose type declares constants in a package outside the patterns then failed:The dependency's positions named the module path instead of the file on disk.
-trimpath=falseis always written, because an emptyGOFLAGSreads as unset and brings the file's value back. Other flags from the file (-mod,-tags) are kept.Not breaking.
Checks
gofmt,
go vet ./...,go test ./gen/. A new test setsGOENVto a file withGOFLAGS=-trimpathand generates a model whose enum type lives in an unloaded package; it fails before this change. Another test coversgo envfailing.🤖 Generated with Claude Code