Re: [go-nuts] Escape special shell characters when using os.Getenv

2016-09-25 Thread Matt Harden
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

2016-09-25 Thread Matt Harden
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

2016-09-19 Thread weiteng . huang
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.