Skip to content

Instantly share code, notes, and snippets.

@j16r
Created November 9, 2015 15:31
Show Gist options
  • Save j16r/66d7fa01d2b754faad94 to your computer and use it in GitHub Desktop.
Save j16r/66d7fa01d2b754faad94 to your computer and use it in GitHub Desktop.
`go vet` treats Logf as a special function, even for custom definitions. `go` used to do this, but looks like it was fixed in 1.5.
package main
import "fmt"
type Level int
const CODE Level = 1
type Logger struct {
}
func (l *Logger) Logf(code Level, message string, args ...interface{}) {
fmt.Printf("Code(%d) %s", code, fmt.Sprintf(message, args))
}
func main() {
logger := Logger{}
logger.Logf(CODE, "Hello %s", "World")
}
@j16r
Copy link
Author

j16r commented Nov 9, 2015

go vet logf.go
logf.go:18: constant 1 not a string in call to Logf
exit status 1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment