FAQ
Hello,

Here is a small program to reproduce the issue:


package main

func log(fmt string, args ...interface{}) {}

func main() {
log("%d", 42)
}


Write it in, say, vetfail.go, then run go vet ./vetfail.go.

Expected output: nothing
Actual output:

vetfail.go:6: possible formatting directive in log call
exit status 1


This should fail with other functions in this
list: https://github.com/golang/tools/blob/578c521fc29d6b5e17e052d4382ef72664fc1e2d/cmd/vet/print.go#L73-L80


-- Baptiste

--
You received this message because you are subscribed to the Google Groups "golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Search Discussions

  • Rob Pike at Jun 22, 2015 at 8:07 pm
    Vet assumes that if a printing function has a name that ends with f, it
    uses a format and if it does not, it does not. This is idiomatic usage in
    Go.

    Thus if you changed the name of your function to logf you would be
    complaint-free.

    You can also control the list of printing functions with the -printfuncs
    flag, but the 'f' rule applies regardless.

    -rob

    On Tue, Jun 23, 2015 at 2:11 AM, wrote:

    Hello,

    Here is a small program to reproduce the issue:


    package main

    func log(fmt string, args ...interface{}) {}

    func main() {
    log("%d", 42)
    }


    Write it in, say, vetfail.go, then run go vet ./vetfail.go.

    Expected output: nothing
    Actual output:

    vetfail.go:6: possible formatting directive in log call
    exit status 1


    This should fail with other functions in this list:
    https://github.com/golang/tools/blob/578c521fc29d6b5e17e052d4382ef72664fc1e2d/cmd/vet/print.go#L73-L80


    -- Baptiste

    --
    You received this message because you are subscribed to the Google Groups
    "golang-nuts" group.
    To unsubscribe from this group and stop receiving emails from it, send an
    email to golang-nuts+unsubscribe@googlegroups.com.
    For more options, visit https://groups.google.com/d/optout.
    --
    You received this message because you are subscribed to the Google Groups "golang-nuts" group.
    To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscribe@googlegroups.com.
    For more options, visit https://groups.google.com/d/optout.
  • Baptiste Fontaine at Jun 23, 2015 at 7:32 am
    Thank you, that makes sense.

    -- Baptiste
    On Monday, June 22, 2015 at 10:07:15 PM UTC+2, Rob 'Commander' Pike wrote:

    Vet assumes that if a printing function has a name that ends with f, it
    uses a format and if it does not, it does not. This is idiomatic usage in
    Go.

    Thus if you changed the name of your function to logf you would be
    complaint-free.

    You can also control the list of printing functions with the -printfuncs
    flag, but the 'f' rule applies regardless.

    -rob


    On Tue, Jun 23, 2015 at 2:11 AM, <baptiste...@batch.com <javascript:>>
    wrote:
    Hello,

    Here is a small program to reproduce the issue:


    package main

    func log(fmt string, args ...interface{}) {}

    func main() {
    log("%d", 42)
    }


    Write it in, say, vetfail.go, then run go vet ./vetfail.go.

    Expected output: nothing
    Actual output:

    vetfail.go:6: possible formatting directive in log call
    exit status 1


    This should fail with other functions in this list:
    https://github.com/golang/tools/blob/578c521fc29d6b5e17e052d4382ef72664fc1e2d/cmd/vet/print.go#L73-L80


    -- Baptiste

    --
    You received this message because you are subscribed to the Google Groups
    "golang-nuts" group.
    To unsubscribe from this group and stop receiving emails from it, send an
    email to golang-nuts...@googlegroups.com <javascript:>.
    For more options, visit https://groups.google.com/d/optout.
    --
    You received this message because you are subscribed to the Google Groups "golang-nuts" group.
    To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscribe@googlegroups.com.
    For more options, visit https://groups.google.com/d/optout.
  • Константин Иванов at May 30, 2016 at 4:04 pm
    It looks like the vet command also says "possible formatting directive in
    Log call" for t.Log("%"), t.Log("%{Yo-ho-ho}")etc.

    понедельник, 22 июня 2015 г., 23:07:15 UTC+3 пользователь Rob 'Commander'
    Pike написал:
    Vet assumes that if a printing function has a name that ends with f, it
    uses a format and if it does not, it does not. This is idiomatic usage in
    Go.

    Thus if you changed the name of your function to logf you would be
    complaint-free.

    You can also control the list of printing functions with the -printfuncs
    flag, but the 'f' rule applies regardless.

    -rob


    On Tue, Jun 23, 2015 at 2:11 AM, <baptiste...@batch.com <javascript:>>
    wrote:
    Hello,

    Here is a small program to reproduce the issue:


    package main

    func log(fmt string, args ...interface{}) {}

    func main() {
    log("%d", 42)
    }


    Write it in, say, vetfail.go, then run go vet ./vetfail.go.

    Expected output: nothing
    Actual output:

    vetfail.go:6: possible formatting directive in log call
    exit status 1


    This should fail with other functions in this list:
    https://github.com/golang/tools/blob/578c521fc29d6b5e17e052d4382ef72664fc1e2d/cmd/vet/print.go#L73-L80


    -- Baptiste

    --
    You received this message because you are subscribed to the Google Groups
    "golang-nuts" group.
    To unsubscribe from this group and stop receiving emails from it, send an
    email to golang-nuts...@googlegroups.com <javascript:>.
    For more options, visit https://groups.google.com/d/optout.
    --
    You received this message because you are subscribed to the Google Groups "golang-nuts" group.
    To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscribe@googlegroups.com.
    For more options, visit https://groups.google.com/d/optout.

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
groupgolang-nuts @
categoriesgo
postedJun 22, '15 at 5:55p
activeMay 30, '16 at 4:04p
posts4
users3
websitegolang.org

People

Translate

site design / logo © 2022 Grokbase