Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fmt: Scan returns "unexpected EOF" instead of io.EOF when arguments have a custom Scan method #17246

Open
kaisuke opened this issue Sep 27, 2016 · 4 comments
Labels
NeedsDecision Feedback is required from experts, contributors, and/or the community before a change can be made.
Milestone

Comments

@kaisuke
Copy link

kaisuke commented Sep 27, 2016

What version of Go are you using (go version)?

go version go1.7.1 linux/amd64

What operating system and processor architecture are you using (go env)?

GOARCH="amd64"
GOBIN=""
GOEXE=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOOS="linux"
GOPATH="/home/kai/work/go"
GORACE=""
GOROOT="/home/kai/opt/go"
GOTOOLDIR="/home/kai/opt/go/pkg/tool/linux_amd64"
CC="gcc"
GOGCCFLAGS="-fPIC -m64 -pthread -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build253151644=/tmp/go-build -gno-record-gcc-switches"
CXX="g++"
CGO_ENABLED="1"

What did you do?

https://play.golang.org/p/L6XtKIJIFb

What did you expect to see?

1 <nil> 42
1 <nil> 42
0 EOF 0
0 EOF 0

What did you see instead?

1 <nil> 42
1 <nil> 42
0 EOF 0
0 unexpected EOF 0
@minux
Copy link
Member

minux commented Sep 27, 2016 via email

@kaisuke
Copy link
Author

kaisuke commented Sep 27, 2016

Thanks. I don't think it's a math/big problem, because I get io.ErrUnexpectedEOF with my own type too:
https://play.golang.org/p/O7kfU9oDFq

Here, my Scanner returns io.EOF, but fmt.Sscan changes it to io.ErrUnexpectedEOF. I don't understand the rationale behind this. Looking at the comments for the two error values, I feel that io.EOF is appropriate for my two examples because we're not encountering EOF in the middle of a data structure.

@minux
Copy link
Member

minux commented Sep 27, 2016 via email

@quentinmit quentinmit added this to the Go1.8Maybe milestone Oct 3, 2016
@quentinmit quentinmit added the NeedsDecision Feedback is required from experts, contributors, and/or the community before a change can be made. label Oct 3, 2016
@rsc rsc modified the milestones: Go1.9, Go1.8Maybe Nov 2, 2016
@bradfitz bradfitz modified the milestones: Go1.10, Go1.9 Jun 7, 2017
@rsc rsc modified the milestones: Go1.10, Go1.11 Nov 22, 2017
@gopherbot gopherbot modified the milestones: Go1.11, Unplanned May 23, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
NeedsDecision Feedback is required from experts, contributors, and/or the community before a change can be made.
Projects
None yet
Development

No branches or pull requests

7 participants
@bradfitz @rsc @quentinmit @minux @kaisuke @gopherbot and others