-
Notifications
You must be signed in to change notification settings - Fork 42
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
allow go statements invoke inline function #111
Comments
I think you have something defined on the line above your go statement, I cannot reproduce with your code. package main
func main() {
go func() {
fn()
}()
}
func fn() {} $ wsl ./main.go && echo $?
0
$ golangci-lint run --no-config --disable-all --enable wsl && echo $?
0 However, if I do something like this: package main
func main() {
x := 1
go func() {
fn()
}()
_ = x
}
func fn() {} I can reproduce it:
The solution here would be to add a newline between your assignment and the package main
func main() {
x := 1
go func() {
fn()
}()
_ = x
}
func fn() {} $ wsl ./main.go && echo $?
0 |
There was a variable assigned line before. Indeed removing assignment results with no error. |
Yes, this is a bad error message. If you look at the docs it comes from when you define a function but call another one. But in fact, this holds true for anything above, not just other functions. I actually regret having so many different error messages, they could all just say something like "Should add an empty line to increase readability" or something similar. I have some plans to drop all checks that are not just missing empty lines. When doing this I will also change to a static single message for every situation. More information about that in #110. |
I'll close this since the behaviour is expected. The real issue here is the bad error message. This is addressed in #110 and I don't think it's reasonable to change such behaviour without a new major release, that would f.ex. break existing regex ignores used in Let me know if you want me to re-open this issue to adress something else! |
Currently for code like this
wsl reports
go statements can only invoke functions assigned on line above
but here there are no function assignement and it is perfectly clear what is invoked
So please allow this king of invocation with
go
statementThe text was updated successfully, but these errors were encountered: