siriele2x3 | 29 Jun 2012 11:28
Picon

fmt Scanln skipping 1st character of new word

My question here is why is scanln skipping the 1st character after the first word in the scan results? for me this isnt terribly important but it is some what troubling because i do not know if I am using this library wrong or if this is a bug, I have out put attched...dont worry about the double printing that is done on purpose. I have the output attached...what i type is what comes before the ">" and what gets scanned in, and printed twice, is the result of reading in that "in" variable....Am i doing this wrong and/or is that a big....its like 430 am and my brain is shitting down...any help/ insight would be greatly appreciated. I dont think i have upgraded this go to the latest 1.02 btw..could that be it?

    line:=" "
    for{
       var in string
      _,ierr := fmt.Scanln(&in)
      fmt.Print(in," ")
      line += in
      if ierr == nil || ierr.Error() == "unexpected newline"{
        break
      }else if ierr.Error() =="Scan: expected newline"{
        line+=" "
      }
    }

outputs
>ok
ok  ok :  1
[ 2 ]
>hello man
hello an  hello an :  2
[ 3737, 67 ]
>what is going on here
what s oing n ere  what s oing n ere :  5
[ 497, 2, 2, 2 ]
>


here is my environment info:

siriele <at> siriele-MS-7681:~/Documents/PassingThoughts/wordsets$ go version
go version go1
siriele <at> siriele-MS-7681:~/Documents/PassingThoughts/wordsets$ go env
GOROOT="/usr/lib/go"
GOBIN=""
GOARCH="amd64"
GOCHAR="6"
GOOS="linux"
GOEXE=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOTOOLDIR="/usr/lib/go/pkg/tool/linux_amd64"
GOGCCFLAGS="-g -O2 -fPIC -m64 -pthread"
CGO_ENABLED="1"
siriele <at> siriele-MS-7681:~/Documents/PassingThoughts/wordsets$ 



Gmane