-
Notifications
You must be signed in to change notification settings - Fork 7
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
feat: allow to specify Go version #31
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I comment my opinion. And please add new example on README.md
Hello @sivchari, I hope this message finds you well. When you have a moment, could you please review this? Your feedback would be greatly appreciated. Thank you in advance! |
Hello @alexandear Sorry, I've missed your commits. I'll check it this week. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How about extracting the Go version from go.mod ? If the options is passed, tenv use it, but if not set, it does search from go.mod.
I'm welcome to feedback, thanks.
} | ||
|
||
if lower { | ||
// Do nothing because T.Setenv added in go1.17 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it's better to print the warning about specifying lower or empty version. What do you think ?
} | ||
|
||
parts := strings.Split(version, ".") | ||
if len(parts) != 2 { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If 1.17.N is passed, this linter occurs an error at this line. Is this intent ?
if err != nil { | ||
return false, fmt.Errorf("go version major part must be a number: %w", err) | ||
} | ||
if major < 1 { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If Go become Go2 in the future (probably not), this linter must doesn't work. So I think this doesn't need. What do you think ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The linter might be actual even on Go2. But I can remove this check, no problem.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's remove this check, thanks.
Hi, @alexandear |
Loading the Go version from For example, the gosec team did this in securego/gosec#1119. However, this led to a performance problem, as seen in golangci/golangci-lint#4735. |
Co-authored-by: sivchari <shibuuuu5@gmail.com>
I propose not adding this flag to not overcomplicate linter's code. Thank you for reviewing this PR. |
This PR adds
-go
flag to specify Go version. This is needed forgolangci-lint
to skip runningtenv
if the Go version is lower than1.17
. BecauseT.Setenv
was added ingo1.17
.