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

False positive when exporting a pointer to a loop variable field. #18

Closed
joeblubaugh opened this issue Jan 26, 2022 · 1 comment
Closed
Assignees

Comments

@joeblubaugh
Copy link

Like so:

package main

import "fmt"

func main() {
	type S struct {
		I int
	}

	structs := []S{S{1}, S{2}}

	var myI *int
	for _, s := range structs {
		myI = &s.I
	}

	fmt.Println(*myI)
}

We do this a fair amount in my team's code, and it feels awkward to introduce a second variable like

i := s.I
myI = &i

or to use a //nolint directive.

@kyoh86
Copy link
Owner

kyoh86 commented Jan 26, 2022

This is a linter to find the matter like such code.
Please read README.md.

@kyoh86 kyoh86 closed this as completed Jan 26, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants