Re: [go-nuts] Escape special shell characters when using os.Getenv
This also works: https://play.golang.org/p/JOJ7WLIUY3 On Sun, Sep 25, 2016 at 3:53 PM Matt Harden wrote: > There is no escaping mechanism built in to os.Expand. > > One workaround would be to define an environment variable containing a > dollar sign: https://play.golang.org/p/InJx2_EWB2 > Another is to substitute an unused character or string and replace it > after expansion: https://play.golang.org/p/j8Oa3dgdoH > > > > On Mon, Sep 19, 2016 at 9:38 AM wrote: > >> I tried to `escape` dollar sign when using os.Getenv; >> I found that golang doesn’t do exactly what I expect (for example >> `$$var_one` —> print `$var_one`). >> Any suggestion? >> https://play.golang.org/p/8fXS4QfCIi , >> my temporary solution requires copying code from golang os pkg >> https://play.golang.org/p/nnsK9llwvr >> >> -- >> 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. >> For more options, visit https://groups.google.com/d/optout. >> > -- 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. For more options, visit https://groups.google.com/d/optout.
Re: [go-nuts] Escape special shell characters when using os.Getenv
There is no escaping mechanism built in to os.Expand. One workaround would be to define an environment variable containing a dollar sign: https://play.golang.org/p/InJx2_EWB2 Another is to substitute an unused character or string and replace it after expansion: https://play.golang.org/p/j8Oa3dgdoH On Mon, Sep 19, 2016 at 9:38 AM wrote: > I tried to `escape` dollar sign when using os.Getenv; > I found that golang doesn’t do exactly what I expect (for example > `$$var_one` —> print `$var_one`). > Any suggestion? > https://play.golang.org/p/8fXS4QfCIi , > my temporary solution requires copying code from golang os pkg > https://play.golang.org/p/nnsK9llwvr > > -- > 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. > For more options, visit https://groups.google.com/d/optout. > -- 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. For more options, visit https://groups.google.com/d/optout.
[go-nuts] Escape special shell characters when using os.Getenv
I tried to `escape` dollar sign when using os.Getenv; I found that golang doesn’t do exactly what I expect (for example `$$var_one` —> print `$var_one`). Any suggestion? https://play.golang.org/p/8fXS4QfCIi , my temporary solution requires copying code from golang os pkg https://play.golang.org/p/nnsK9llwvr -- 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. For more options, visit https://groups.google.com/d/optout.