On Thu, 1 Dec 2022 01:39:38 -0800 (PST)
"hey...@gmail.com" <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:
> 
> 1. go generate
> 2. -ldflags="-X 'main.Path=..."
> 
> Both seem to be flawed. For #1, the blog clearly stated that it's
> designed for package author, and not for clients (and go generate
> doesn't support passing arguments to //go:generate anyways). For #2,
> the path can't be a constant.
> 

Whats wrong with const? And could not be global var then?

-- 
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/20221201171436.5f1922fc%40inspiro.localdomain.

Attachment: pgpQO6OkK7Mda.pgp
Description: OpenPGP digital signature

Reply via email to