aboutsummaryrefslogtreecommitdiffstats
path: root/vendor/github.com/Antonboom/errname/pkg
diff options
context:
space:
mode:
authordependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>2023-08-22 02:02:22 +0000
committerTaras Madan <tarasmadan@google.com>2023-08-22 12:20:16 +0000
commit91132985a7ff76db390949ac765113cfd3178fa7 (patch)
tree9dcdece9df519c487f06e1b7a824c7ddd571ce53 /vendor/github.com/Antonboom/errname/pkg
parent81191e0ae93e179f148ee4f89deedfe444d7baaa (diff)
mod: do: bump github.com/golangci/golangci-lint from 1.54.1 to 1.54.2
Bumps [github.com/golangci/golangci-lint](https://github.com/golangci/golangci-lint) from 1.54.1 to 1.54.2. - [Release notes](https://github.com/golangci/golangci-lint/releases) - [Changelog](https://github.com/golangci/golangci-lint/blob/master/CHANGELOG.md) - [Commits](https://github.com/golangci/golangci-lint/compare/v1.54.1...v1.54.2) --- updated-dependencies: - dependency-name: github.com/golangci/golangci-lint dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] <support@github.com>
Diffstat (limited to 'vendor/github.com/Antonboom/errname/pkg')
-rw-r--r--vendor/github.com/Antonboom/errname/pkg/analyzer/analyzer.go17
-rw-r--r--vendor/github.com/Antonboom/errname/pkg/analyzer/facts.go12
2 files changed, 18 insertions, 11 deletions
diff --git a/vendor/github.com/Antonboom/errname/pkg/analyzer/analyzer.go b/vendor/github.com/Antonboom/errname/pkg/analyzer/analyzer.go
index 6425db137..aa8522510 100644
--- a/vendor/github.com/Antonboom/errname/pkg/analyzer/analyzer.go
+++ b/vendor/github.com/Antonboom/errname/pkg/analyzer/analyzer.go
@@ -1,6 +1,7 @@
package analyzer
import (
+ "fmt"
"go/ast"
"go/token"
"strconv"
@@ -25,16 +26,16 @@ func New() *analysis.Analyzer {
type stringSet = map[string]struct{}
var (
- imports = []ast.Node{(*ast.ImportSpec)(nil)}
- types = []ast.Node{(*ast.TypeSpec)(nil)}
- funcs = []ast.Node{(*ast.FuncDecl)(nil)}
+ importNodes = []ast.Node{(*ast.ImportSpec)(nil)}
+ typeNodes = []ast.Node{(*ast.TypeSpec)(nil)}
+ funcNodes = []ast.Node{(*ast.FuncDecl)(nil)}
)
func run(pass *analysis.Pass) (interface{}, error) {
insp := pass.ResultOf[inspect.Analyzer].(*inspector.Inspector)
pkgAliases := map[string]string{}
- insp.Preorder(imports, func(node ast.Node) {
+ insp.Preorder(importNodes, func(node ast.Node) {
i := node.(*ast.ImportSpec)
if n := i.Name; n != nil && i.Path != nil {
if path, err := strconv.Unquote(i.Path.Value); err == nil {
@@ -45,14 +46,14 @@ func run(pass *analysis.Pass) (interface{}, error) {
allTypes := stringSet{}
typesSpecs := map[string]*ast.TypeSpec{}
- insp.Preorder(types, func(node ast.Node) {
+ insp.Preorder(typeNodes, func(node ast.Node) {
t := node.(*ast.TypeSpec)
allTypes[t.Name.Name] = struct{}{}
typesSpecs[t.Name.Name] = t
})
errorTypes := stringSet{}
- insp.Preorder(funcs, func(node ast.Node) {
+ insp.Preorder(funcNodes, func(node ast.Node) {
f := node.(*ast.FuncDecl)
t, ok := isMethodError(f)
if !ok {
@@ -62,7 +63,7 @@ func run(pass *analysis.Pass) (interface{}, error) {
tSpec, ok := typesSpecs[t]
if !ok {
- panic("no specification for type " + t)
+ panic(fmt.Sprintf("no specification for type %q", t))
}
if _, ok := tSpec.Type.(*ast.ArrayType); ok {
@@ -75,7 +76,7 @@ func run(pass *analysis.Pass) (interface{}, error) {
})
errorFuncs := stringSet{}
- insp.Preorder(funcs, func(node ast.Node) {
+ insp.Preorder(funcNodes, func(node ast.Node) {
f := node.(*ast.FuncDecl)
if isFuncReturningErr(f.Type, allTypes, errorTypes) {
errorFuncs[f.Name.Name] = struct{}{}
diff --git a/vendor/github.com/Antonboom/errname/pkg/analyzer/facts.go b/vendor/github.com/Antonboom/errname/pkg/analyzer/facts.go
index 8711f9cf5..06f8d61d8 100644
--- a/vendor/github.com/Antonboom/errname/pkg/analyzer/facts.go
+++ b/vendor/github.com/Antonboom/errname/pkg/analyzer/facts.go
@@ -1,8 +1,10 @@
package analyzer
import (
+ "fmt"
"go/ast"
"go/token"
+ "go/types"
"strings"
"unicode"
)
@@ -34,15 +36,19 @@ func isMethodError(f *ast.FuncDecl) (typeName string, ok bool) {
if i, ok := v.X.(*ast.Ident); ok {
return i.Name
}
+ case *ast.IndexListExpr:
+ if i, ok := v.X.(*ast.Ident); ok {
+ return i.Name
+ }
}
- return ""
+ panic(fmt.Errorf("unsupported Error() receiver type %q", types.ExprString(e)))
}
switch rt := f.Recv.List[0].Type; v := rt.(type) {
- case *ast.Ident, *ast.IndexExpr: // SomeError, SomeError[T]
+ case *ast.Ident, *ast.IndexExpr, *ast.IndexListExpr: // SomeError, SomeError[T], SomeError[T1, T2, ...]
receiverType = unwrapIdentName(rt)
- case *ast.StarExpr: // *SomeError, *SomeError[T]
+ case *ast.StarExpr: // *SomeError, *SomeError[T], *SomeError[T1, T2, ...]
receiverType = unwrapIdentName(v.X)
}