air-verse / air

☁️ Live reload for Go apps
GNU General Public License v3.0
16.39k stars 773 forks source link

[Question]: how go install command populating version.go file variables #513

Open KunalSin9h opened 6 months ago

KunalSin9h commented 6 months ago

I know how to use ldflags with goreleaser to populate variables at build time. But doing go install how air is setting these variables.

@cosmtrek can you help me?

piyushdatazip commented 3 days ago

Hi @KunalSin9h actually I also tried to add ldflags via cmd but somehow Air is not setting up these flags, but when executing the same command in terminal they do embed the values in the binary

KunalSin9h commented 2 days ago

via cmd

@piyushdatazip how ?

piyushdatazip commented 2 days ago

@KunalSin9h I triggered a make command that sets-up the ldflags which works if I fire in terminal but doesn't when Air is firing that.

KunalSin9h commented 2 days ago

I dont understand why you want Air to build your app. Air is not designed for building using ldflags its for development only.

piyushdatazip commented 2 days ago

Air is not designed for building using ldflags its for development only.

@KunalSin9h Is it specially mentioned somewhere?

I mean why does that even matter? Air is supposed to detect changes in my files and refire my cmd and bin command.

Why specially I need to build is because my program uses variables injected with ldflags so they're unchangeable and aren't picked-up from environment variables and due to that I do need to build for "development" because that's how our system is designed.

There could be difference in approach here, and something else might be suited better for me, but that's what I want, and if you could redirect to something else that can help achieve this, that would be great.

KunalSin9h commented 2 days ago

Out of mind i dont have any resource but i will try to recreate what you are doing. And lets we if this is achievable