You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
What steps will reproduce the problem?
Execute from a machine with internet access this code:
http://play.golang.org/p/F2zKRm_qW1
What is the expected output?
Word read: aboriginally
Last word: aboriginally
FirstWord: aa
Word count: 447
Word read: aboriginals
Last word: aboriginals
FirstWord: aa
Word count: 448
Word read: aborigine
Last word: aborigine
FirstWord: aa
Word count: 449
Word read: aborigines
Last word: aborigines
FirstWord: aa
Word count: 450
What do you see instead?
Word read: aboriginally
Last word: aboriginally
FirstWord: aa
Word count: 447
Word read: aboriginals
Last word: aboriginals
FirstWord: aa
Word count: 448
Word read: aborigine
Last word: aborigine
FirstWord: ab
Word count: 449
Word read: aborigines
Last word: aborigines
FirstWord: ab
Word count: 450
Which compiler are you using (5g, 6g, 8g, gccgo)?
gc
Which operating system are you using?
Windows7 x64
Which version are you using? (run 'go version')
go version go1.1.1 windows/amd64
Please provide any additional information below.
Program reads words separated by '\n' from a file and appends them to an array. append
work ok until iteration 449. At this point it seems the contents are stored in position
0 (instead of appending), but the size of element 0 is not changed (see attached debug
information for details).
I have reproduced the problem when reading from a local file, but not when generating
contents inside the program.
bufio.Reader.ReadLine has docs about the lifetime of its returned value:
"The returned buffer is only valid until the next call to ReadLine. ReadLine either
returns a non-nil line or it returns an error, never both."
Use ReadString or ReadBytes instead.
by borja.roux:
Attachments:
The text was updated successfully, but these errors were encountered: