-
Notifications
You must be signed in to change notification settings - Fork 2.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
go/analysis/passes/nilness: handle type assertions too
This change causes nilness to detect patterns of the form: ptr, ok := x.(T) if !ok { println(*ptr) // nil dereference } It found three bugs in k8s, e.g. // pkg/controller/volume/persistentvolume/pv_controller.go claim, ok = obj.(*v1.PersistentVolumeClaim) if !ok { return fmt.Errorf("cannot convert object from volume cache to volume %q!?: %#v", claim.Spec.VolumeName, obj) } Fixes golang/go#47938 Change-Id: Idb4588ce037cb898ccc3feb460ea0b67f65803df Reviewed-on: https://go-review.googlesource.com/c/tools/+/560075 LUCI-TryBot-Result: Go LUCI <[email protected]> Reviewed-by: Tim King <[email protected]>
- Loading branch information
Showing
2 changed files
with
82 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters