Re: [go-nuts] fmt verb to single quote text

2017-01-06 Thread messju mohr
If you want to generate javascript code I suggest the encoding/json package from the stdlib. Like: https://play.golang.org/p/vHKcCfWJPz On Thu, Jan 05, 2017 at 09:06:06AM -0800, bsr wrote: >Alexander. thank you very much for helping out.  >your program does output my desired string, but v

Re: [go-nuts] fmt verb to single quote text

2017-01-05 Thread bsr
Andrew.. thank you so much. that works great.. On Thursday, January 5, 2017 at 3:37:51 PM UTC-5, Diddymus wrote: > > Maybe https://play.golang.org/p/9EewyQhD3U ? > > On Thursday, 5 January 2017 17:06:07 UTC, bsr wrote: >> >> Alexander. thank you very much for helping out. >> your program does out

Re: [go-nuts] fmt verb to single quote text

2017-01-05 Thread Diddymus
Maybe https://play.golang.org/p/9EewyQhD3U ? On Thursday, 5 January 2017 17:06:07 UTC, bsr wrote: > > Alexander. thank you very much for helping out. > your program does output my desired string, but value is read from parsing > struct comment and not sure how to get the same effect of multi lin

Re: [go-nuts] fmt verb to single quote text

2017-01-05 Thread bsr
Alexander. thank you very much for helping out. your program does output my desired string, but value is read from parsing struct comment and not sure how to get the same effect of multi line string `hello ... \n world` In other word, my input is "hello ... \n world" and not sure how to convert

Re: [go-nuts] fmt verb to single quote text

2017-01-05 Thread Matthew Singletary
If you are using it in a fmt string (like your example), you can use the '%q' formatting verb (like this example ). On Thu, Jan 5, 2017 at 11:45 AM bsr wrote: Please see the example https://play.golang.org/p/SeG7oO5Us0 I am doing some javascript codegen a

Re: [go-nuts] fmt verb to single quote text

2017-01-05 Thread Alexander Kapshuk
On Thu, Jan 5, 2017 at 6:45 PM, bsr wrote: > Please see the example https://play.golang.org/p/SeG7oO5Us0 > > I am doing some javascript codegen and I want my values single quoted. so, > in the above example, I want the output to be > > > { v: 'hello ... \n world'} > > > instead of > > { v: '"hello

[go-nuts] fmt verb to single quote text

2017-01-05 Thread bsr
Please see the example https://play.golang.org/p/SeG7oO5Us0 I am doing some javascript codegen and I want my values single quoted. so, in the above example, I want the output to be { v: 'hello ... \n world'} instead of { v: '"hello ... \n world"'} or { v: "hello ... \n world"} how can I do