Repository navigation
fix: 版本元数据注入——Project/GitCommit 不再为空 - #32
Merged
Merged
Conversation
funk v2 的版本变量全部为未导出,go build -X 无法注入,旧 ldflags 全部失效: - .goreleaser.yaml / Taskfile 移除失效的 -X 注入 - main.go 改为 SetProject + SetCommitID(读 runtime/debug vcs.revision, go install 与 goreleaser 构建均会盖章)+ 原有 SetVersion(embedded VERSION) - Taskfile 顺带移除不存在的 -mod vendor(仓库无 vendor 目录) 验证: 本地构建后 version 输出 Project=protobuild Version=v0.3.0 GitCommit=85abe65
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.
问题
protobuild version的 Project / GitCommit 自始至终为空(v0.2.1 起就如此)。根因:funk v2 的版本变量(
version/project/commitID)全部未导出,go build -X只能注入导出变量,.goreleaser.yaml 与 Taskfile 里的 ldflags 全部静默失效。修复
main.go:SetProject+SetCommitID(读runtime/debug的vcs.revision,go install / goreleaser 构建都会自动盖章)+ 原有
SetVersion(embedded .version/VERSION).goreleaser.yaml:移除失效 ldflagsTaskfile.yml:移除失效 ldflags 与不存在的-mod vendor验证
Project: protobuild / Version: v0.3.0 / GitCommit: 85abe65全部正确