• Spencer Nelson's avatar
    cmd/vet: Use function signature to find format string index. · 867910ea
    Spencer Nelson authored
    cmd/vet's printf checker currently uses a hardcoded map of function
    names to expected positions of format strings. We can be a bit more
    precise than this by looking up the signature of the function, which
    helps when libraries implement functions like Errorf or Logf with
    extra arguments like log levels or error codes.
    
    Specifically, the format string param is assumed to be the last string
    parameter of the called function.
    
    Fixes #12294.
    
    Change-Id: Icf10ebb819bba91fa1c4109301417042901e34c7
    Reviewed-on: https://go-review.googlesource.com/20163
    Run-TryBot: Rob Pike <r@golang.org>
    TryBot-Result: Gobot Gobot <gobot@golang.org>
    Reviewed-by: 's avatarRob Pike <r@golang.org>
    867910ea
print.go 13.7 KB