@Nick @Brian Somehow I missed your replies.
Using a Makefile makes sense. And thanks for bringing embed to my attention. I never knew it exists. Sounds like it can solve my problem. Thanks a lot. On Thursday, December 1, 2022 at 6:32:58 PM UTC+8 Nick wrote: > 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/b120021e-17c3-4cae-8f94-d3d67570713an%40googlegroups.com.