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

cmd/vet: %w in Printf call should be flagged #35472

Open
josharian opened this issue Nov 8, 2019 · 5 comments
Assignees
Milestone

Comments

@josharian
Copy link
Contributor

@josharian josharian commented Nov 8, 2019

package main

import (
	"errors"
	"fmt"
)

func main() {
	err := errors.New("ABC")
	fmt.Printf("error: %w\n", err)
}

https://play.golang.org/p/-kQ6HtIIMG7

vet should complain about the %w verb. Only in Errorf format strings does it have meaning.

@bcmills

This comment has been minimized.

Copy link
Member

@bcmills bcmills commented Nov 8, 2019

@bcmills bcmills added this to the Backlog milestone Nov 8, 2019
@mvdan mvdan added the Suggested label Nov 9, 2019
@mvdan

This comment has been minimized.

Copy link
Member

@mvdan mvdan commented Nov 9, 2019

This also seems like a pretty simple issue for anyone wanting to get started contributing to vet.

@Inconnu08

This comment has been minimized.

Copy link
Contributor

@Inconnu08 Inconnu08 commented Nov 12, 2019

I would love to take a shot on this. Any pointers to get started on this issue?

@agnivade

This comment has been minimized.

Copy link
Contributor

@agnivade agnivade commented Nov 12, 2019

The file in question is this one - https://github.com/golang/tools/blob/master/go/analysis/passes/printf/printf.go. Look at how other verbs are handled and take it from there.

@Inconnu08

This comment has been minimized.

Copy link
Contributor

@Inconnu08 Inconnu08 commented Nov 12, 2019

Ah I'm on the right track then. Thank you! I'm working on this 😃

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
5 participants
You can’t perform that action at this time.