Thanks to visit codestin.com
Credit goes to github.com

Skip to content

fix(cmd/gf): fix gf env and gf build --dumpEnv command error#4635

Merged
gqcn merged 1 commit intogogf:masterfrom
lingcoder:bugfix/gf-env-dumpEnv-error
Jan 21, 2026
Merged

fix(cmd/gf): fix gf env and gf build --dumpEnv command error#4635
gqcn merged 1 commit intogogf:masterfrom
lingcoder:bugfix/gf-env-dumpEnv-error

Conversation

@lingcoder
Copy link
Contributor

Summary

  • Fix gf env and gf build --dumpEnv command failing when go env outputs warning messages
  • When go env outputs warnings (e.g., invalid characters in environment variables), it returns non-zero exit code but still provides valid output
  • The original code would fail in this case

Changes

  • Only fail when go env returns empty output, allow non-zero exit code with valid output
  • Skip lines that don't match key=value format instead of failing with Fatal error
  • Add debug log for skipped lines to help troubleshooting
  • Add unit tests for env command

Related Issue

Fixes #4469

Test plan

  • gf env command works correctly even when go env outputs warnings
  • gf build --dumpEnv works correctly
  • Added unit tests pass

@lingcoder lingcoder force-pushed the bugfix/gf-env-dumpEnv-error branch from d4c6b26 to c26cf56 Compare January 20, 2026 06:26
When go env outputs warning messages (e.g., "go: stripping unprintable
characters from GOPROXY") and returns non-zero exit code, the gf env
command would fail.

Changes:
- Only fail when go env returns empty output, allow non-zero exit code
  with valid output
- Skip lines that don't match key=value format instead of failing
- Add debug log for skipped lines
- Add unit tests for env command
@lingcoder lingcoder force-pushed the bugfix/gf-env-dumpEnv-error branch from e97712c to 031914d Compare January 20, 2026 06:29
@gqcn
Copy link
Member

gqcn commented Jan 21, 2026

/lgtm

@gqcn gqcn merged commit 095c69c into gogf:master Jan 21, 2026
18 checks passed
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.

gf build --dumpEnv 编译前打印环境变量报错

2 participants