gofrs / uuid

A UUID package for Go
MIT License
1.57k stars 110 forks source link

New %S verb causes `go vet` failure in go 1.12.x, not 1.11.x or tip #77

Closed theckman closed 3 years ago

theckman commented 5 years ago

The new %S verb seems to cause go vet in Go 1.12.x to fail when vetting code that tries to use it, as it believes %S is not a supported verb. This does not fail for 1.11.x or tip. A Go issue was opened to track this: https://github.com/golang/go/issues/31000.

This is blocking the release of v3.3.0, and v4.0.0 (#71).

$ go vet file.go
# command-line-arguments
./bleh.go:14:2: Printf format %S has unknown verb S
package main

import (
    "log"

    "github.com/gofrs/uuid"
)

func main() {
    u2, err := uuid.NewV4()
    if err != nil {
        log.Fatalf("failed to generate UUID: %v", err)
    }
    log.Printf("capitalized UUID: %S\n", u2) /* ERROR HERE !! */
}

// Example output:
// 2019/03/22 01:17:20 capitalized UUID: 8BB2BE92-2573-435A-8A4C-CAD633636165
dylan-bourque commented 5 years ago

Just tried this w/ Go 1.12.1 on my laptop (Ubuntu 18.04). No error from go vet. :confused:

go version -> go version go1.12.1 linux/amd64 go env:

GOARCH="amd64"
GOBIN=""
GOCACHE="/home/dylan/.cache/go-build"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOOS="linux"
GOPATH="/home/dylan/dev/golang"
GOPROXY=""
GORACE=""
GOROOT="/usr/local/go"
GOTMPDIR=""
GOTOOLDIR="/usr/local/go/pkg/tool/linux_amd64"
GCCGO="gccgo"
CC="gcc"
CXX="g++"
CGO_ENABLED="1"
GOMOD=""
CGO_CFLAGS=""
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS=""
PKG_CONFIG="pkg-config"
GOGCCFLAGS="-fPIC -m64 -pthread -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build244704731=/tmp/go-build -gno-record-gcc-switches"

/tmp/test.go:

package main

import (
    "fmt"
    "github.com/gofrs/uuid"
)

func main() {
    u := uuid.Must(uuid.NewV4())
    fmt.Printf("capitalized UUID: %S", u)
}
dylan-bourque commented 5 years ago

Seems to be an issue w/ go vet -> https://github.com/golang/go/issues/31000#issuecomment-475648810

dylan-bourque commented 5 years ago

Should be fixed in Go 1.21.2 per https://github.com/golang/go/issues/30399

dylan-bourque commented 4 years ago

Apologies for abandoning this. Life happens. ( ._.)

I just verified that go vet is clean when run against the example program @theckman posted above using Go 1.13.1. I don't have an easy way to test against a 1.12 environment.

cameracker commented 3 years ago

This issue appears to have been fixed up stream. Closing for now!