Hi!

Not an expert at all, but it seems the format is
"package-qualified.identifier=value", with value being able to just contain
spaces out of the box, so running:

go run -ldflags="-X 'main.MyVar=this is a string'" main.go

works for me. Note that for parsing the whole thing correctly, the whole
equality should be surrounded by quotes (i.e. including the main.MyVar part)

Hope that helps!

On Thu, Nov 9, 2023 at 10:26 PM Tong Sun <suntong...@gmail.com> wrote:

> go run command-line-arguments
>
>   -X definition
>         add string value definition of the form importpath.name=value
>
> I used to use this to override my variable values, in the form of
>
> go run -ldflags="-X main.var1=val1 main.var2=val2"
>
> Now, the new problem is that I need to have space in the string value
> definition. How can I do that please?
>
> I've tried both the following cases:
>
> go run -ldflags="-X main.var1='val 1' main.var2=\"val 2\""
>
> but neither is working.
> Please help
>
>
> --
> 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/7d1e2b06-dce9-4e46-b20b-fe5a3663038en%40googlegroups.com
> <https://groups.google.com/d/msgid/golang-nuts/7d1e2b06-dce9-4e46-b20b-fe5a3663038en%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
>

-- 
*Évènement en ligne : inscription ici 
<https://info.doctolib.fr/events/bienvenue-dans-le-nouveau-doctolib/?utm_campaign=nurt_FR_Generic_email_signature_20231030&utm_source=automation&utm_medium=email>
*
_The information transmitted, including attachments, is intended only for 
_the _person(s) or _entity to which it is addressed and may contain 
_confidential and/or privileged material. Any _review, retransmission, 
_dissemination or other use of, or taking of any action in reliance _upon 
_this information by persons or entities other than the intended recipient 
_is prohibited. If _you received this in error, please contact the sender 
and _destroy any copies of this _information._____________

-- 
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/CAMaoJVmy5ut5_FtQy_6HDESgM4SHCewyC9RVqBRTg8WpHOnTxQ%40mail.gmail.com.

Reply via email to