Re: [go-nuts] Why no bytes.InsertByte(s []byte, p int, b byte) []byte ?

2016-10-18 Thread Aram Hăvărneanu
> On Mon, Oct 17, 2016 at 8:29 PM, Liam Breck wrote: >> bytes.Replace(s []byte, pos int, len uint, new []byte) > > I have no idea what this bizarre hypothetical function does. It's an > awful interface that aims to solve an unknown problem nobody has > claimed to have. >

Re: [go-nuts] Why no bytes.InsertByte(s []byte, p int, b byte) []byte ?

2016-10-18 Thread Aram Hăvărneanu
On Mon, Oct 17, 2016 at 8:29 PM, Liam Breck wrote: > bytes.Replace(s []byte, pos int, len uint, new []byte) I have no idea what this bizarre hypothetical function does. It's an awful interface that aims to solve an unknown problem nobody has claimed to have. Also,

Re: [go-nuts] Why no bytes.InsertByte(s []byte, p int, b byte) []byte ?

2016-10-17 Thread Liam Breck
On Oct 16, 2016 6:03 PM, "Liam Breck" wrote: > > > > On Sun, Oct 16, 2016 at 5:32 PM, Ian Lance Taylor wrote: >> >> On Sun, Oct 16, 2016 at 5:25 PM, Liam wrote: >> > >> > On Sunday, October 16, 2016 at 5:13:36 PM UTC-7, Ian

Re: [go-nuts] Why no bytes.InsertByte(s []byte, p int, b byte) []byte ?

2016-10-16 Thread Liam Breck
On Sun, Oct 16, 2016 at 5:32 PM, Ian Lance Taylor wrote: > On Sun, Oct 16, 2016 at 5:25 PM, Liam wrote: > > > > On Sunday, October 16, 2016 at 5:13:36 PM UTC-7, Ian Lance Taylor wrote: > >> > >> On Sun, Oct 16, 2016 at 3:34 PM, Liam

Re: [go-nuts] Why no bytes.InsertByte(s []byte, p int, b byte) []byte ?

2016-10-16 Thread Ian Lance Taylor
On Sun, Oct 16, 2016 at 5:25 PM, Liam wrote: > > On Sunday, October 16, 2016 at 5:13:36 PM UTC-7, Ian Lance Taylor wrote: >> >> On Sun, Oct 16, 2016 at 3:34 PM, Liam wrote: >> > >> > On Sunday, October 16, 2016 at 2:56:42 PM UTC-7, Ian Lance Taylor

Re: [go-nuts] Why no bytes.InsertByte(s []byte, p int, b byte) []byte ?

2016-10-16 Thread Liam
On Sunday, October 16, 2016 at 5:13:36 PM UTC-7, Ian Lance Taylor wrote: > > On Sun, Oct 16, 2016 at 3:34 PM, Liam > wrote: > > > > On Sunday, October 16, 2016 at 2:56:42 PM UTC-7, Ian Lance Taylor wrote: > > > >> To argue that this should go into the standard

Re: [go-nuts] Why no bytes.InsertByte(s []byte, p int, b byte) []byte ?

2016-10-16 Thread Ian Lance Taylor
On Sun, Oct 16, 2016 at 3:34 PM, Liam wrote: > > On Sunday, October 16, 2016 at 2:56:42 PM UTC-7, Ian Lance Taylor wrote: > >> To argue that this should go into the standard library, look at some >> corpus of Go code and find out how often it occurs. If it occurs >>

Re: [go-nuts] Why no bytes.InsertByte(s []byte, p int, b byte) []byte ?

2016-10-16 Thread Liam
On Sunday, October 16, 2016 at 2:56:42 PM UTC-7, Ian Lance Taylor wrote: > > > > A function to insert a byte into a slice is conspicuous by its absence. > > It's a one-liner. > append(s[:p], append([]byte{b}, s[p:]...)...) > This is already gobbledygook :) Does that read "Insert" to

Re: [go-nuts] Why no bytes.InsertByte(s []byte, p int, b byte) []byte ?

2016-10-16 Thread Ian Lance Taylor
On Sun, Oct 16, 2016 at 1:49 PM, Liam wrote: > > A function to insert a byte into a slice is conspicuous by its absence. It's a one-liner. append(s[:p], append([]byte{b}, s[p:]...)...) (You may want to look at https://github.com/golang/go/wiki/SliceTricks). >

[go-nuts] Why no bytes.InsertByte(s []byte, p int, b byte) []byte ?

2016-10-16 Thread Liam
A function to insert a byte into a slice is conspicuous by its absence. Consider this code to parse /proc/meminfo into a 2D array and insert commas: MemTotal: 497464 kB MemFree: 386232 kB MemAvailable: 452420 kB Buffers:8612 kB Cached: