Skip to content
This repository has been archived by the owner on Jun 27, 2023. It is now read-only.

allow version flag to work when built with goroleaser #389

Closed
codyoss opened this issue Jan 22, 2020 · 5 comments · Fixed by #394
Closed

allow version flag to work when built with goroleaser #389

codyoss opened this issue Jan 22, 2020 · 5 comments · Fixed by #394
Assignees

Comments

@codyoss
Copy link
Member

codyoss commented Jan 22, 2020

Actual behavior A clear and concise description of what the bug is.

When building locally unable to retrieve a version. This makes it hard should we want to publish pre-built binaries.

git clone https://github.com/golang/mock.git
go build ./...
.mockgen/mockgen -version` outputs `(devlel)

Expected behavior A clear and concise description of what you expected to
happen.

mockgen -version outputs version info.

  • gomock version or git ref: v1.4.0
  • golang version: 1.13.6
@minicuts minicuts self-assigned this Jan 22, 2020
@minicuts
Copy link
Contributor

minicuts commented Jan 22, 2020

@codyoss what are the commands that you use to get mockgen? This is what I get:

nguyenfilip@nguyenfilip:~$ GO111MODULE=on go get github.com/golang/mock/mockgen@latest
go: finding github.com/golang/mock v1.4.0
go: downloading github.com/golang/mock v1.4.0
go: extracting github.com/golang/mock v1.4.0
nguyenfilip@nguyenfilip:~$ mockgen -version
v1.4.0

My go version:

nguyenfilip@nguyenfilip:~$ go version
go version go1.13.4 linux/amd64

@codyoss codyoss changed the title fix version flag allow version flag to work when built with go build Jan 22, 2020
@codyoss
Copy link
Member Author

codyoss commented Jan 22, 2020

Sorry, you are right that does work. The use case I ran into was for us publishing prebuilt binaries. Updated initial steps. Thoughts?

@minicuts
Copy link
Contributor

minicuts commented Jan 22, 2020

What are the steps that you use to prebuild binaries? I will check if we can build in a way that it includes the module info. As a sidenote: As I mentioned in the description of #362, the best way to support prebuilt binaries would be to combine the current approach with build flags (-ldflags). Note that the build flags approach is useful only for prebuild binaries. It would not help at all when running go get - which is what most of our users seem to be doing.

@codyoss
Copy link
Member Author

codyoss commented Jan 22, 2020

Good point on the ldflags. That would work fine. I will using goreleaser to make the binaries. That does allow for custom flags to be sent through. goreleaser release --skip-publish --skip-validate --rm-dist is the command I used locally to do a dry run that builds the binaries. Note there is a small bug in the config right now I noticed when I was playing with it last night. If we could just update that to pass the proper flags though I think that is good enough.

@minicuts
Copy link
Contributor

@codyoss I will check the goroleaser. It would be nice if we mitigated a need for build flags

@minicuts minicuts changed the title allow version flag to work when built with go build allow version flag to work when built with goroleaser Jan 23, 2020
@minicuts minicuts mentioned this issue Jan 31, 2020
3 tasks
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants