Re: [go-nuts] What's go's convention for specifying the equivolent of configure --prefix?

2022-12-03 Thread Nick White
On Thu, Dec 01, 2022 at 08:42:46PM -0800, hey...@gmail.com wrote: > 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. Yeah, embed is brilliant, I'm glad it can help you. One thing I forgot to mention

Re: [go-nuts] What's go's convention for specifying the equivolent of configure --prefix?

2022-12-01 Thread hey...@gmail.com
@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

Re: [go-nuts] What's go's convention for specifying the equivolent of configure --prefix?

2022-12-01 Thread Glen Huang
@m.shulhan @hervinhioslash Thanks for the suggestion. I agree that using a runtime mechanism like env vars or command line flag can solve this problem. But the path value is for internal use, it should be customized only by the system administrators or package managers who determine where to

Re: [go-nuts] What's go's convention for specifying the equivolent of configure --prefix?

2022-12-01 Thread Kyle
I'd use godotenv in this case. True, it will require a .env file with a path variable in it and true it won't be as having consts but it will do the job. import ( "os" "github.com/joho/godotenv" ) func init() { if os.Getenv("MODE") != "PROD" { godotenv.Load() } } // ... //

Re: [go-nuts] What's go's convention for specifying the equivolent of configure --prefix?

2022-12-01 Thread Shulhan
On Thu, 1 Dec 2022 18:21:37 +0800 Glen Huang wrote: > > Whats wrong with const? > > Const is the ideal choice, but how do users of my program specify the > path when they compile it? > They can't, but in Go, I am leaning to prefer where user can set the "prefix" when running the program

Re: [go-nuts] What's go's convention for specifying the equivolent of configure --prefix?

2022-12-01 Thread Nick
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

Re: [go-nuts] What's go's convention for specifying the equivolent of configure --prefix?

2022-12-01 Thread Glen Huang
> Whats wrong with const? Const is the ideal choice, but how do users of my program specify the path when they compile it? > And could not be global var then? Using var loses the guarantee that the path won’t be changed, and the go compiler can no longer optimize as much I presume? -- You

Re: [go-nuts] What's go's convention for specifying the equivolent of configure --prefix?

2022-12-01 Thread Shulhan
On Thu, 1 Dec 2022 01:39:38 -0800 (PST) "hey...@gmail.com" wrote: > I'm writing a command line program in go, and it needs to access some > predefined external files like /usr/lib/name/file. What would be a > good way to allow specify the constant path in compile time? > > I see two options: >

[go-nuts] What's go's convention for specifying the equivolent of configure --prefix?

2022-12-01 Thread hey...@gmail.com
I'm writing a command line program in go, and it needs to access some predefined external files like /usr/lib/name/file. What would be a good way to allow specify the constant path in compile time? I see two options: 1. go generate 2. -ldflags="-X 'main.Path=..." Both seem to be flawed. For