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

caseOrder: type is not defined if type is defined in another file in the same package #1288

Open
Ivan-Feofanov opened this issue Nov 3, 2022 · 3 comments
Labels
question Further information is requested

Comments

@Ivan-Feofanov
Copy link

I put my struct type definition into separate file named shema.go and added this typeswitch statement:

switch value := payload.(type) {
case CustomerLead: // <-- this is my struct type
    // do something
default:
    log.Printf("Don't know what to do with %v", value)
}

And if I run gocritic as gocritic check file-with-switch.go as a result I got an error

caseOrder: type is not defined CustomerLead

I don't wanna put all my code in one file 😸 Have any ideas how it can be fixed?

@cristaloleg
Copy link
Member

cristaloleg commented Nov 3, 2022

Try to run gocritic on all package, not one file.

@Ivan-Feofanov
Copy link
Author

But I wanna use it in pre-commit hook which runs only on stages files

@cristaloleg
Copy link
Member

Not sure but this might be done by golangci-lint https://golangci-lint.run/usage/configuration/#issues-configuration

@cristaloleg cristaloleg added the question Further information is requested label Feb 10, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants