On Thu, Dec 01, 2022 at 06:21:37PM +0800, Glen Huang wrote:
> Const is the ideal choice, but how do users of my program specify the path 
> when
> they compile it?

I don't think this is something for which there is a "canonical Go
way", so I'd say something like a tiny makefile that sets the path
with the PREFIX environment variable, passing that to -ldflags as
you suggested.

> Using var loses the guarantee that the path won’t be changed, and the go
> compiler can no longer optimize as much I presume?

I don't think it being var rather than const is going to be an
optimization bottleneck. But if it really was important, then you
could use a makefile to insert / overwrite a line with sed or
similar, keeping some sensible default working for users who
eschewed the makefile and just used 'go install' or whatever.

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/Y4iCu6bsve0Q7PlM%40mussel.lan.

Reply via email to