Skip to content
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

Pull version from single SoT (main.go) #61

Merged
merged 2 commits into from
Nov 30, 2024
Merged

Conversation

mmonaco
Copy link
Contributor

@mmonaco mmonaco commented Nov 30, 2024

This might be helpful, no worries otherwise :)

This could go the other way around too, stamping it in with -ldflags='-X appVersion=$(VERSION)'

This could go the other way around too, stamping it in with `-ldflags='-X appVersion=$(VERSION)'`
@maximbaz
Copy link
Owner

Thanks! I think I most often saw others use the alternative -ldflags way, let's do it that way!

@mmonaco
Copy link
Contributor Author

mmonaco commented Nov 30, 2024

Thanks! I think I most often saw others use the alternative -ldflags way, let's do it that way!

Sure, will do.

The difference is whether you only want a version to come from the build system so that you'd get something like:

$ go run main.go --version
YubiKey touch detector version: <UNDEFINED>

@maximbaz
Copy link
Owner

Hmmm very good point, sorry allow me to change my mind, let's go with your current version 😅

@maximbaz
Copy link
Owner

Would there be any downsides with the simpler sed command like the one I pushed?

@mmonaco
Copy link
Contributor Author

mmonaco commented Nov 30, 2024

Would there be any downsides with the simpler sed command like the one I pushed?

Not really. The main difference is that I was trying to be flexible with

const appVersion =

vs

const (
  appVersion = ...
)

@maximbaz
Copy link
Owner

OK I'll be mindful about it, thanks!

@maximbaz maximbaz merged commit e4c41a9 into maximbaz:main Nov 30, 2024
@mmonaco
Copy link
Contributor Author

mmonaco commented Nov 30, 2024

OOC, unrelated, why do you vendor the deps like this? I think this is meant for checking in the deps. If you're going to .gitignore the vendor dir, why not let the default go pkg cache be used?

@maximbaz
Copy link
Owner

I add a tarball with vendored dependencies to the release only because some distros build (or prefer to build) offline, which is a problem if they need to allow internet to run go get.

I haven't been using Makefile for local development for a while, I suppose it's not correct that my local target depends on vendor, it shouldn't. Was this the part that made you ask about it?

@mmonaco
Copy link
Contributor Author

mmonaco commented Nov 30, 2024

Ah, that make sense! Yeah I saw it show up when I did make run.

I guess you could have:

.PHONY: run
run: build
        ./$(BIN)

and drop local altogether

@maximbaz
Copy link
Owner

Agree, just pushed 👍

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.

2 participants