Re: [go-nuts] Re: reading with scanner.Bytes()

2016-08-30 Thread Rob Pike
There's a 50% chance the receiver wants a string, in which case it would be simpler to use scanner.Text(). -rob On Wed, Aug 31, 2016 at 9:11 AM, Mateusz Czapliński wrote: > > > W dniu wtorek, 30 sierpnia 2016 05:30:48 UTC+2 użytkownik chri...@uber.com > napisał: >> >> How to efficiently create

[go-nuts] Re: reading with scanner.Bytes()

2016-08-30 Thread Mateusz Czapliński
W dniu wtorek, 30 sierpnia 2016 05:30:48 UTC+2 użytkownik chri...@uber.com napisał: > > How to efficiently create a new []byte slice that's not shared? > The simple way I can think of is to []byte(string(bytes)). > Alternatively, I'd expect the following should work: outChannel <- append([]b

[go-nuts] Re: reading with scanner.Bytes()

2016-08-30 Thread adonovan via golang-nuts
On Monday, 29 August 2016 23:30:48 UTC-4, chri...@uber.com wrote: > > I am reading a file line by line, and send it to a chan []byte, and > consume it on another goroutine. > > However, I found I must create a new []byte, because the scanner.Bytes() > returned a []byte slice that's shared, and th