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: x format verb for []byte fails in a recursive call to Fscanf from a scanln call in go1.5rc1 #12090

Closed
ghost opened this issue Aug 10, 2015 · 2 comments
Milestone

Comments

@ghost
Copy link

@ghost ghost commented Aug 10, 2015

Consider the following code:

package main

import "fmt"

type arr [2]byte

func (x *arr) Scan(ss fmt.ScanState, verb rune) error {
    var b []byte
    _, err := fmt.Fscanf(ss, "%4x", &b)
    copy((*x)[:], b)
    return err
}

func main() {
    var x arr
    n, err := fmt.Sscanln("0123\n", &x)
    fmt.Println(n, err, x)
}

In go1.4.2 this prints 1 <nil> [1 35], but go1.5rc1 linux/amd64 gives me 1 expected newline [1 35], which doesn't seem right. Changing the format verb to 's' makes the error go away.

@ghost ghost changed the title fmt: Scanner fmt: x format verb for strings fails in a recursive call to Fscanf from a scanln call Aug 10, 2015
@ghost ghost changed the title fmt: x format verb for strings fails in a recursive call to Fscanf from a scanln call fmt: x format verb for strings fails in a recursive call to Fscanf from a scanln call in go1.5rc1 Aug 10, 2015
@davecheney
Copy link
Contributor

@davecheney davecheney commented Aug 10, 2015

@hubslave can you please provide a code sample that demonstrates the issue.

@ghost ghost changed the title fmt: x format verb for strings fails in a recursive call to Fscanf from a scanln call in go1.5rc1 fmt: x format verb for []byte fails in a recursive call to Fscanf from a scanln call in go1.5rc1 Aug 10, 2015
@robpike
Copy link
Contributor

@robpike robpike commented Aug 10, 2015

Nice bug, easy fix coming.

@robpike robpike closed this in fe3d8d4 Aug 10, 2015
@mikioh mikioh added this to the Go1.5 milestone Aug 10, 2015
@golang golang locked and limited conversation to collaborators Aug 9, 2016
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
4 participants
You can’t perform that action at this time.