Join GitHub today
GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.Sign up
GitHub is where the world builds software
Millions of developers and companies build, ship, and maintain their software on GitHub — the largest and most advanced development platform in the world.
fmt: Sscanf %c skips a blank in Go1.5; not in Go1.3.3, nor in C #12275
What version of Go are you using (go version)?
I found this when upgrading from Go 1.3.3 to Go 1.5
What operating system and processor architecture are you using?
What did you do?
$ cat scango.go
What did you expect to see?
I expected what Go 1.3.3 did: it always gets the first character in the scanned string, either "A" or " ":
That's also what my C compiler does
$ gcc scanc.c
What did you see instead?
Under Go 1.5, it skips the blank, and advances to the "A" (in the second clause) or EOF (in the third clause):
1.4 also gets a space. Arguably, it's doing what the docs say, but this new behavior, a consequence of a major internal restructuring, is clearly a change in behavior. Should perhaps be fixed. I wish instead we could just tell everyone not to use fmt.Scan*. I wish they had never been written.
…kip spaces at %c In short, %c should just give you the next rune, period. Apparently this is the design. I use the term loosely. Fixes #12275 Change-Id: I6f30bed442c0e88eac2244d465c7d151b29cf393 Reviewed-on: https://go-review.googlesource.com/13821 Reviewed-by: Andrew Gerrand <firstname.lastname@example.org> Reviewed-on: https://go-review.googlesource.com/14395