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: Sscanf doc disagrees with implementation #12788

Closed
bcmills opened this issue Sep 29, 2015 · 6 comments
Closed

fmt: Sscanf doc disagrees with implementation #12788

bcmills opened this issue Sep 29, 2015 · 6 comments

Comments

@bcmills
Copy link
Contributor

bcmills commented Sep 29, 2015

https://golang.org/pkg/fmt/#Sscanf says:

Newlines in the input must match newlines in the format.

However, in the current implementation, trailing newlines in the format string are treated as matching the end of the input string:
http://play.golang.org/p/r2f16aAYbS

Either the package documentation or the implementation should be updated. (Probably the package documentation, since a significant number of programs are likely already relying on this behavior.)

@cznic
Copy link
Contributor

cznic commented Sep 29, 2015

Newlines in the input must match newlines in the format.

There's no newline in input in the linked example, ie. there's nothing to match. Compare with, for example, http://play.golang.org/p/k8KMqjPRFa

@bcmills
Copy link
Contributor Author

bcmills commented Sep 29, 2015

There's no newline in input in the linked example, ie. there's nothing to match.

Yes, that's the point. According to the documentation, fmt.Sscanf should return an error in this case (as it does for, say, http://play.golang.org/p/T1_RAgYLC-).

That is: according to the documentation, the newline in the format string should require a corresponding newline in the input string in order to return a nil error. It currently does not.

@gopherbot
Copy link

CL https://golang.org/cl/16165 mentions this issue.

@rsc
Copy link
Contributor

rsc commented Oct 23, 2015

Up to Rob.

2 similar comments
@rsc
Copy link
Contributor

rsc commented Oct 23, 2015

Up to Rob.

@rsc
Copy link
Contributor

rsc commented Oct 23, 2015

Up to Rob.

@rsc rsc added this to the Go1.6 milestone Oct 23, 2015
@rsc rsc added the Thinking label Oct 23, 2015
@golang golang locked and limited conversation to collaborators Nov 27, 2016
@rsc rsc unassigned robpike Jun 23, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

5 participants