-
Notifications
You must be signed in to change notification settings - Fork 235
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Load sdk version from buildinfo #521
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It seems GetVersion()
cannot retrieval github.com/line/line-bot-sdk-go build info. only itself deps.
Have you ever try it?
I created minimum samples for this case. it worked as expected. About lib repositoryhttps://github.com/Yang-33/line-bot-sdk-go-521-lib This provides simple http-client calling Below app uses this. (or you can use this library in your app) about app repositoryhttps://github.com/Yang-33/line-bot-sdk-go-521-app This just uses https://github.com/Yang-33/line-bot-sdk-go-521-lib (lib repository like line-bot-sdk-go), and other libraries. When the app uses library provided in https://github.com/Yang-33/line-bot-sdk-go-521-lib, it shows all dependencies the app uses. like
Therefore, I believe this change is working as expected. In the user app, line-bot-sdk-go can obtain its version from buildinfo. I believe we no longer need to write the version in |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, I don't have any more question. Thank you.
Thank you for your review! |
Currently, line-bot-sdk-go embeds the library version defined in
version.go
as the user-agent, soversion.go
is updated manually or forcibly at release time to avoid manual operation. And we define a github workflow to push tag forcibly to automate (1) updatingversion.go
and (2)fix git tag. Because of this, GitHub's branch protection cannot be used. (we can solve this by using PAT, but we don't want to use it)Since Go 1.18, https://pkg.go.dev/debug/buildinfo has been provided. By using runtime/debug, library(like line-bot-sdk-go) can obtain the library's own version from the runtime of the library user. Since the latest version of line-bot-sdk-go only supports Go 1.22 and above, this feature should be usable.
In the user's environment, the version of line-bot-sdk-go is retrieved from buildinfo only once in runtime. There's no point in recalculating it each time since the same value should be obtained every time.
Excluding meaningless mocks, tests in this repository cannot be written. I created minimum example for this patch.