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: All errors begin with the string "%!", sometimes. #5730

Closed
peterGo opened this issue Jun 19, 2013 · 4 comments
Closed

fmt: All errors begin with the string "%!", sometimes. #5730

peterGo opened this issue Jun 19, 2013 · 4 comments
Milestone

Comments

@peterGo
Copy link
Contributor

peterGo commented Jun 19, 2013

Package fmt

Format errors:

Wrong type or unknown verb: %!verb(type=value)
    Printf("%d", hi):          %!d(string=hi)
Too many arguments: %!(EXTRA type=value)
    Printf("hi", "guys"):      hi%!(EXTRA string=guys)
Too few arguments: %!verb(MISSING)
    Printf("hi%d"):            hi %!d(MISSING)
Non-int for width or precision: %!(BADWIDTH) or %!(BADPREC)
    Printf("%*s", 4.5, "hi"):  %!(BADWIDTH)hi
    Printf("%.*s", 4.5, "hi"): %!(BADPREC)hi
Invalid or invalid use of argument index: %!(BADINDEX)
    Printf("%*[2]d", 7):       %d(BADINDEX)
    Printf("%.[2]d", 7):       %d(BADINDEX)

All errors begin with the string "%!".

The documentation error descriptions are correct. All errors begin with the string
"%!".

The documentation sample output is sometimes incorrect:

Printf("%*[2]d", 7):       %d(BADINDEX)
Printf("%.[2]d", 7):       %d(BADINDEX)

The actual output is sometimes incorrect:

hi%d(MISSING)
%d(BADINDEX)
%d(BADINDEX)

go version devel +4298a713c372 Tue Jun 18 17:15:26 2013 -0700 linux/amd64

package main

import (
    . "fmt"
)

func main() {
    // package fmt
    // fmt/doc.go
    // Format errors:

    hi := "hi"
    // Wrong type or unknown verb: %!verb(type=value)
    Printf("%d", hi) // :          %!d(string=hi)
    Println()
    // Too many arguments: %!(EXTRA type=value)
    Printf("hi", "guys") // :      hi%!(EXTRA string=guys)
    Println()
    // Too few arguments: %!verb(MISSING)
    Printf("hi%d") // :            hi %!d(MISSING)
    Println()
    // Non-int for width or precision: %!(BADWIDTH) or %!(BADPREC)
    Printf("%*s", 4.5, "hi") // :  %!(BADWIDTH)hi
    Println()
    Printf("%.*s", 4.5, "hi") // : %!(BADPREC)hi
    Println()
    // Invalid or invalid use of argument index: %!(BADINDEX)
    Printf("%*[2]d", 7) // :       %d(BADINDEX)
    Println()
    Printf("%.[2]d", 7) // :       %d(BADINDEX)
    Println()

    // All errors begin with the string "%!".

}

http://play.golang.org/p/Ojl6QtD_RZ

Output:

%!d(string=hi)
hi%!(EXTRA string=guys)
hi%d(MISSING)
%!(BADWIDTH)hi
%!(BADPREC)hi
%d(BADINDEX)
%d(BADINDEX)
@robpike
Copy link
Contributor

robpike commented Jun 19, 2013

Comment 1:

Labels changed: added priority-soon, removed priority-triage.

Owner changed to @robpike.

Status changed to Accepted.

@rsc
Copy link
Contributor

rsc commented Jul 30, 2013

Comment 2:

Labels changed: added go1.2.

@robpike
Copy link
Contributor

robpike commented Jul 31, 2013

Comment 3:

This issue was closed by revision 02ad82f.

Status changed to Fixed.

@robpike
Copy link
Contributor

robpike commented Jul 31, 2013

Comment 4:

This issue was closed by revision 53b6105.

@rsc rsc added this to the Go1.2 milestone Apr 14, 2015
@rsc rsc removed the go1.2 label Apr 14, 2015
@golang golang locked and limited conversation to collaborators Jun 24, 2016
@rsc rsc unassigned robpike Jun 22, 2022
This issue was closed.
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

4 participants