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 , str include " #12564

scroot opened this issue Sep 10, 2015 · 3 comments

fmt: Sscanf , str include " #12564

scroot opened this issue Sep 10, 2015 · 3 comments


Copy link

@scroot scroot commented Sep 10, 2015

package main

import (

func main() {

    cmd := exec.Command(`c:\windows\system32\where.exe`, `/f`, "/t", "*.txt")
    buf, err := cmd.Output()
    if err != nil {
    var i int
    var str string
    fmt.Sscanf(string(buf), `%d   2015/8/23      12:59:38  "%s"`, &i, &str)
    fmt.Println(i, str)
    fmt.Fprintf(os.Stdout, "%s", buf)



1649 C:\Windows\System32\WindowsCodecsRaw.txt"
1649 2015/8/23 12:59:38 "C:\Windows\System32\WindowsCodecsRaw.txt"

@adg adg changed the title fmt.Sscanf , str include " fmt: Sscanf , str include " Sep 10, 2015
Copy link

@scroot scroot commented Sep 10, 2015

system: window 10 x64
go version: go1.5.1 windows/amd64

Copy link

@adg adg commented Sep 10, 2015

What's the issue?

@minux minux closed this Sep 10, 2015
Copy link

@minux minux commented Sep 10, 2015

I think what the OP meant is this program:

fmt.Sscanf(1649 2015/8/23 12:59:38 "C:\Windows\System32\WindowsCodecsRaw.txt", %d 2015/8/23 12:59:38 "%s", &i, &str)

The scanned str will contain the right double-quote character.

This is working as intended. Scanf %s will keep scanning until it encounters
any space characters.

%s and %v on strings scan a space-delimited token

PS: Please ask questions like this on the mailing list. If you use English,
golang-nuts, or if you prefer Chinese, golang-china.

@golang golang locked and limited conversation to collaborators Sep 22, 2016
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
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.