Skip to content

gen: drop -trimpath set in the go env file - #11

Merged
emoss08 merged 1 commit into
masterfrom
gen-trimpath-goenv
Nov 25, 2026
Merged

emoss08 merged 1 commit into
masterfrom
gen-trimpath-goenv

Conversation

@emoss08

@emoss08 emoss08 commented Nov 25, 2026

Copy link
Copy Markdown
Owner

What changes

keel gen now reads the effective GOFLAGS from go env, which honors both the environment and the go env file. It passes that value to the package loader without -trimpath and with -trimpath=false.

Why

The loader dropped -trimpath only from a GOFLAGS environment variable. A -trimpath set with go env -w GOFLAGS=-trimpath still applied. A model field whose type declares constants in a package outside the patterns then failed:

Order.Status: parse example.com/app/kinds/kinds.go: open example.com/app/kinds/kinds.go: no such file or directory

The dependency's positions named the module path instead of the file on disk. -trimpath=false is always written, because an empty GOFLAGS reads 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 sets GOENV to a file with GOFLAGS=-trimpath and generates a model whose enum type lives in an unloaded package; it fails before this change. Another test covers go env failing.

🤖 Generated with Claude Code

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>
@emoss08
emoss08 merged commit 0cf0a98 into master Nov 25, 2026
0 of 2 checks passed
@emoss08
emoss08 deleted the gen-trimpath-goenv branch November 25, 2026 20:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant