Re: [go-nuts] How to wrap an arbitrary data with extra data (and then pass to Template)

2018-05-02 Thread Tong Sun
On Wed, May 2, 2018 at 7:32 PM, Burak Serdar wrote: I think passing in a map is the easiest solution. Agree, however, I'm trying to provide a general library that take arbitrary data just like the text Template does, so imposing this will make my old code broken. If all you need is to pass ENV

Re: [go-nuts] How to wrap an arbitrary data with extra data (and then pass to Template)

2018-05-02 Thread Burak Serdar
On Wed, May 2, 2018 at 5:18 PM, Tong Sun wrote: > > > On Wed, May 2, 2018 at 12:06 PM, Jan Mercl wrote: >> >> >> Ugly hack, completely wrong in the general case: >> https://play.golang.org/p/IM_lxT3PxmR > > > Oh, I now know why it was called "hack", because the thing would get > complicated and

Re: [go-nuts] How to wrap an arbitrary data with extra data (and then pass to Template)

2018-05-02 Thread Tong Sun
On Wed, May 2, 2018 at 12:06 PM, Jan Mercl wrote: > > Ugly hack, completely wrong in the general case: https://play.golang.org/ > p/IM_lxT3PxmR > Oh, I now know why it was called "hack", because the thing would get complicated and out of control very easily, e.g., {{add .v1 .v2}} So, still no

Re: [go-nuts] How to wrap an arbitrary data with extra data (and then pass to Template)

2018-05-02 Thread Tong Sun
On Wed, May 2, 2018 at 12:06 PM, Jan Mercl wrote: > > Ugly hack, completely wrong in the general case: https://play.golang.org/ > p/IM_lxT3PxmR > That's it! -- Only three more Replace statements added, but the *big and complicated *problem is overcame. Brilliant. thx a lot. -- You received this

Re: [go-nuts] How to wrap an arbitrary data with extra data (and then pass to Template)

2018-05-02 Thread Jan Mercl
On Wed, May 2, 2018 at 5:16 PM Tong Sun wrote: Ugly hack, completely wrong in the general case: https://play.golang.org/p/IM_lxT3PxmR -- -j -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receiving ema

Re: [go-nuts] How to wrap an arbitrary data with extra data (and then pass to Template)

2018-05-02 Thread Tong Sun
On Wed, May 2, 2018 at 11:47 AM, Burak Serdar wrote: > >> > // now > >> > env := make(map[string]string) > >> > for _, e := range os.Environ() { > >> > sep := strings.Index(e, "=") > >> > env[e[0:sep]] = e[sep+1:] > >> > } > >> > // how to add env into data as ENV so that it can be accessed

Re: [go-nuts] How to wrap an arbitrary data with extra data (and then pass to Template)

2018-05-02 Thread Burak Serdar
On Wed, May 2, 2018 at 9:32 AM, Tong Sun wrote: > Thanks. but, > > On Wed, May 2, 2018 at 11:27 AM, Burak Serdar wrote: >> >> On Wed, May 2, 2018 at 9:16 AM, Tong Sun wrote: >> > >> > >> > >> > // now >> > env := make(map[string]string) >> > for _, e := range os.Environ() { >> > sep := strings

Re: [go-nuts] How to wrap an arbitrary data with extra data (and then pass to Template)

2018-05-02 Thread Tong Sun
Thanks. but, On Wed, May 2, 2018 at 11:27 AM, Burak Serdar wrote: > On Wed, May 2, 2018 at 9:16 AM, Tong Sun wrote: > > > > > > > > // now > > env := make(map[string]string) > > for _, e := range os.Environ() { > > sep := strings.Index(e, "=") > > env[e[0:sep]] = e[sep+1:] > > } > > // how

Re: [go-nuts] How to wrap an arbitrary data with extra data (and then pass to Template)

2018-05-02 Thread Burak Serdar
On Wed, May 2, 2018 at 9:16 AM, Tong Sun wrote: > > > > // now > env := make(map[string]string) > for _, e := range os.Environ() { > sep := strings.Index(e, "=") > env[e[0:sep]] = e[sep+1:] > } > // how to add env into data as ENV so that it can be accessed within args:=map[string]interfac

[go-nuts] How to wrap an arbitrary data with extra data (and then pass to Template)

2018-05-02 Thread Tong Sun
The text Template can accept an arbitrary data: func (t *Template) Execute(wr io.Writer, data interface{}) error What I'm trying to do is to provide a general library that take an arbitrary data just like the text Template does, then add more