Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix nil ptr bug in checkGenerated (#159)
Currently, while checking if a file contains generated code, if the file doesn't contain any package comment, we run into a nil pointer dereference error. ``` package example ... // rest of the logic ``` **Why** This happens due to missing nil check in the `checkGenerated` function before iterating `ast.File.Doc.List` ([pkg ref](https://pkg.go.dev/go/ast#File)) ``` for _, comm := range f.Doc.List { // nil pointer error when f.Doc is nil ``` This commit adds a nil pointer check in `checkGenerated` to continue with the rest of the logic only if there's a package comment.
- Loading branch information