From 66eb9cb9d9fdb0137b3120689ab41430f2189f6b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=90=D0=BD=D1=82=D0=BE=D0=BD=20=D0=A2=D0=B5=D0=BB=D1=8B?= =?UTF-8?q?=D1=88=D0=B5=D0=B2?= Date: Thu, 22 Jul 2021 12:22:47 +0300 Subject: [PATCH 1/2] Add errname linter --- go.mod | 4 +-- go.sum | 27 +++++++++++------ pkg/golinters/errname.go | 21 +++++++++++++ pkg/lint/lintersdb/manager.go | 4 +++ test/testdata/errname.go | 55 +++++++++++++++++++++++++++++++++++ 5 files changed, 100 insertions(+), 11 deletions(-) create mode 100644 pkg/golinters/errname.go create mode 100644 test/testdata/errname.go diff --git a/go.mod b/go.mod index c8d5d789504e..2bc6a8ad2267 100644 --- a/go.mod +++ b/go.mod @@ -4,6 +4,7 @@ go 1.12 require ( 4d63.com/gochecknoglobals v0.0.0-20201008074935-acfc0b28355a + github.com/Antonboom/errname v0.1.2 github.com/Djarvur/go-err113 v0.0.0-20200511133814-5174e21577d5 github.com/OpenPeeDeeP/depguard v1.0.1 github.com/bombsimon/wsl/v3 v3.1.0 @@ -63,8 +64,7 @@ require ( github.com/ultraware/whitespace v0.0.4 github.com/uudashr/gocognit v1.0.1 github.com/valyala/quicktemplate v1.6.3 - golang.org/x/sys v0.0.0-20201009025420-dfb3f7c4e634 // indirect - golang.org/x/tools v0.0.0-20201013201025-64a9e34f3752 + golang.org/x/tools v0.1.5 gopkg.in/yaml.v2 v2.3.0 honnef.co/go/tools v0.0.1-2020.1.6 mvdan.cc/gofumpt v0.0.0-20200802201014-ab5a8192947d diff --git a/go.sum b/go.sum index 92699332d89f..20c58b705e5c 100644 --- a/go.sum +++ b/go.sum @@ -13,6 +13,8 @@ cloud.google.com/go/firestore v1.1.0/go.mod h1:ulACoGHTpvq5r8rxGJ4ddJZBZqakUQqCl cloud.google.com/go/pubsub v1.0.1/go.mod h1:R0Gpsv3s54REJCy4fxDixWD93lHJMoZTyQ2kNxGRt3I= cloud.google.com/go/storage v1.0.0/go.mod h1:IhtSnM/ZTZV8YYJWCY8RULGVqBDmpoyjwiyrjsg+URw= dmitri.shuralyov.com/gpu/mtl v0.0.0-20190408044501-666a987793e9/go.mod h1:H6x//7gZCb22OMCxBHrMx7a5I7Hp++hsVxbQ4BYO7hU= +github.com/Antonboom/errname v0.1.2 h1:Lg1R0kXPC57BhcK8P8dDjMC4xee7BBBwVxe9M0yOF2A= +github.com/Antonboom/errname v0.1.2/go.mod h1:jRXo3m0E0EuCnK3wbsSVH3X55Z4iTDLl6ZfCxwFj4TM= github.com/BurntSushi/toml v0.3.1 h1:WXkYYl6Yr3qBf1K79EBnL4mak0OimBfB0XUf9Vl28OQ= github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU= github.com/BurntSushi/xgb v0.0.0-20160522181843-27f122750802/go.mod h1:IVnqGOEym/WlBOVXweHU+Q+/VP0lqqI8lqeDx9IjBqo= @@ -56,7 +58,6 @@ github.com/denis-tingajkin/go-header v0.3.1/go.mod h1:sq/2IxMhaZX+RRcgHfCRx/m0M5 github.com/dgrijalva/jwt-go v3.2.0+incompatible/go.mod h1:E3ru+11k8xSBh+hMPgOLZmtrrCbhqsmaPHjLKYnJCaQ= github.com/dgryski/go-sip13 v0.0.0-20181026042036-e10d5fee7954/go.mod h1:vAd38F8PWV+bWy6jNmig1y/TA+kYO4g3RSRF0IAv0no= github.com/fatih/color v1.7.0/go.mod h1:Zm6kSWBoL9eyXnKyktHP6abPY2pDugNf5KwzbycvMj4= -github.com/fatih/color v1.9.0 h1:8xPHl4/q1VyqGIPif1F+1V3Y3lSmrq01EabUW3CoW5s= github.com/fatih/color v1.9.0/go.mod h1:eQcE1qtQxscV5RaZvpXrrb8Drkc3/DdQ+uUYCNjL+zU= github.com/fatih/color v1.10.0 h1:s36xzo75JdqLaaWoiEHk767eHiwo0598uUxyfiPkDsg= github.com/fatih/color v1.10.0/go.mod h1:ELkj/draVOlAH/xkhN6mQ50Qd0MPOk5AAr3maGEBuJM= @@ -280,7 +281,6 @@ github.com/onsi/ginkgo v1.12.1/go.mod h1:zj2OWP4+oCPe1qIXoGWkgMRwljMUYCdkwsT2108 github.com/onsi/ginkgo v1.14.1 h1:jMU0WaQrP0a/YAEq8eJmJKjBoMs+pClEr1vDMlM/Do4= github.com/onsi/ginkgo v1.14.1/go.mod h1:iSB4RoI2tjJc9BBv4NKIKWKya62Rps+oPG/Lv9klQyY= github.com/onsi/gomega v1.7.1/go.mod h1:XdKZgCCFLUoM/7CFJVPcG8C1xQ1AJ0vpAezJrB7JYyY= -github.com/onsi/gomega v1.10.1 h1:o0+MgICZLuZ7xjH7Vx6zS/zcu93/BEp1VwkIW1mEXCE= github.com/onsi/gomega v1.10.1/go.mod h1:iN09h71vgCQne3DLsj+A5owkum+a2tYe+TOCB1ybHNo= github.com/onsi/gomega v1.10.2 h1:aY/nuoWlKJud2J6U0E3NWsjlg+0GtwXxgEqthRdzlcs= github.com/onsi/gomega v1.10.2/go.mod h1:iN09h71vgCQne3DLsj+A5owkum+a2tYe+TOCB1ybHNo= @@ -404,6 +404,7 @@ github.com/yuin/goldmark v1.1.25/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9de github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= github.com/yuin/goldmark v1.1.32/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= +github.com/yuin/goldmark v1.3.5/go.mod h1:mwnBkeHKe2W/ZEtQ+71ViKU8L12m81fl3OWwC1Zlc8k= go.etcd.io/bbolt v1.3.2/go.mod h1:IbVyRI1SCnLcuJnV2u8VeU0CEYM7e686BmAb1XKL+uU= go.opencensus.io v0.21.0/go.mod h1:mSImk1erAIZhrmZN+AvHh14ztQfjbGwt4TtuofqLduU= go.opencensus.io v0.22.0/go.mod h1:+kGneAE2xo2IficOXnaByMWTGM9T73dGwxeWcUqIpI8= @@ -437,8 +438,9 @@ golang.org/x/mod v0.0.0-20190513183733-4bf6d317e70e/go.mod h1:mXi4GBBbnImb6dmsKG golang.org/x/mod v0.1.0/go.mod h1:0QHyrYULN0/3qlju5TqG8bIK38QM8yzMo5ekMj3DlcY= golang.org/x/mod v0.1.1-0.20191105210325-c90efee705ee/go.mod h1:QqPTAvyqsEbceGzBzNggFXnrqF1CaUcvgkdR5Ot7KZg= golang.org/x/mod v0.2.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= -golang.org/x/mod v0.3.0 h1:RM4zey1++hCTbCVQfnWeKs9/IEsaBLA8vTkd0WVtmH4= golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= +golang.org/x/mod v0.4.2 h1:Gz96sIWK3OalVv/I/qNygP42zyoKp3xptRVCWRFEBvo= +golang.org/x/mod v0.4.2/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20180826012351-8a410e7b638d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20180906233101-161cd47e91fd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= @@ -458,8 +460,9 @@ golang.org/x/net v0.0.0-20200226121028-0de0cce0169b/go.mod h1:z5CRVTTTmAJ677TzLL golang.org/x/net v0.0.0-20200520004742-59133d7f0dd7/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A= golang.org/x/net v0.0.0-20200602114024-627f9648deb9/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A= golang.org/x/net v0.0.0-20200625001655-4c5254603344/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA= -golang.org/x/net v0.0.0-20200822124328-c89045814202 h1:VvcQYSHwXgi7W+TpUR6A9g6Up98WAHf3f/ulnJ62IyA= golang.org/x/net v0.0.0-20200822124328-c89045814202/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA= +golang.org/x/net v0.0.0-20210405180319-a5a99cb37ef4 h1:4nGaVu0QrbjT/AK2PRLuQfQuh6DJve+pELhqTdAj3x0= +golang.org/x/net v0.0.0-20210405180319-a5a99cb37ef4/go.mod h1:p54w0d4576C0XHj96bSt6lcn1PtDYWL6XObtHCRCNQM= golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= golang.org/x/oauth2 v0.0.0-20190226205417-e64efc72b421/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= golang.org/x/oauth2 v0.0.0-20190604053449-0f29369cfe45/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= @@ -470,6 +473,7 @@ golang.org/x/sync v0.0.0-20190227155943-e225da77a7e6/go.mod h1:RxMgew5VJxzue5/jJ golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20200625203802-6e8e738ad208/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.0.0-20210220032951-036812b2e83c/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sys v0.0.0-20180823144017-11551d06cbcc/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20180905080454-ebe1bf3edb33/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= @@ -495,12 +499,17 @@ golang.org/x/sys v0.0.0-20200223170610-d5e6a3e2c0ae/go.mod h1:h1NjWce9XRLGQEsW7w golang.org/x/sys v0.0.0-20200323222414-85ca7c5b95cd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200519105757-fe76b779f299/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200602225109-6fdc65e7d980/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20201009025420-dfb3f7c4e634 h1:bNEHhJCnrwMKNMmOx3yAynp5vs5/gRy+XWFtZFu7NBM= -golang.org/x/sys v0.0.0-20201009025420-dfb3f7c4e634/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20210330210617-4fbd30eecc44/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20210510120138-977fb7262007/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20210630005230-0f9fa26af87c h1:F1jZWGFhYfh0Ci55sIpILtKKK8p3i2/krTr0H1rg74I= +golang.org/x/sys v0.0.0-20210630005230-0f9fa26af87c/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.1-0.20180807135948-17ff2d5776d2/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= -golang.org/x/text v0.3.2 h1:tW2bmiBqwgJj/UpqtC8EpXEZVYOwU0yG4iWbprSVAcs= golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk= +golang.org/x/text v0.3.3 h1:cokOdA+Jmi5PJGXLlLllQSgYigAEfHXJAERHVMaCc2k= +golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/time v0.0.0-20181108054448-85acf8d2951c/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= golang.org/x/time v0.0.0-20190308202827-9d24e82272b4/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= golang.org/x/tools v0.0.0-20180221164845-07fd8470d635/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= @@ -547,8 +556,8 @@ golang.org/x/tools v0.0.0-20201001104356-43ebab892c4c/go.mod h1:z6u4i615ZeAfBE4X golang.org/x/tools v0.0.0-20201002184944-ecd9fd270d5d/go.mod h1:z6u4i615ZeAfBE4XtMziQW1fSVJXACjjbWkB/mvPzlU= golang.org/x/tools v0.0.0-20201007032633-0806396f153e/go.mod h1:z6u4i615ZeAfBE4XtMziQW1fSVJXACjjbWkB/mvPzlU= golang.org/x/tools v0.0.0-20201011145850-ed2f50202694/go.mod h1:z6u4i615ZeAfBE4XtMziQW1fSVJXACjjbWkB/mvPzlU= -golang.org/x/tools v0.0.0-20201013201025-64a9e34f3752 h1:2ntEwh02rqo2jSsrYmp4yKHHjh0CbXP3ZtSUetSB+q8= -golang.org/x/tools v0.0.0-20201013201025-64a9e34f3752/go.mod h1:z6u4i615ZeAfBE4XtMziQW1fSVJXACjjbWkB/mvPzlU= +golang.org/x/tools v0.1.5 h1:ouewzE6p+/VEB31YYnTbEJdi8pFqKp4P4n85vwo3DHA= +golang.org/x/tools v0.1.5/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk= golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= diff --git a/pkg/golinters/errname.go b/pkg/golinters/errname.go new file mode 100644 index 000000000000..7ee8113478ba --- /dev/null +++ b/pkg/golinters/errname.go @@ -0,0 +1,21 @@ +package golinters + +import ( + "github.com/Antonboom/errname/pkg/analyzer" + "golang.org/x/tools/go/analysis" + + "github.com/golangci/golangci-lint/pkg/golinters/goanalysis" +) + +func NewErrName() *goanalysis.Linter { + analyzers := []*analysis.Analyzer{ + analyzer.New(), + } + + return goanalysis.NewLinter( + "errname", + "Checks that sentinel errors are prefixed with the `Err` and error types are suffixed with the `Error`.", + analyzers, + nil, + ).WithLoadMode(goanalysis.LoadModeTypesInfo) +} diff --git a/pkg/lint/lintersdb/manager.go b/pkg/lint/lintersdb/manager.go index 52a230bd8053..57e153dafd4b 100644 --- a/pkg/lint/lintersdb/manager.go +++ b/pkg/lint/lintersdb/manager.go @@ -324,6 +324,10 @@ func (m Manager) GetAllSupportedLinterConfigs() []*linter.Config { WithPresets(linter.PresetBugs). WithLoadForGoAnalysis(). WithURL("https://github.com/polyfloyd/go-errorlint"), + linter.NewConfig(golinters.NewErrName()). + WithPresets(linter.PresetStyle). + WithLoadForGoAnalysis(). + WithURL("https://github.com/Antonboom/errname"), // nolintlint must be last because it looks at the results of all the previous linters for unused nolint directives linter.NewConfig(golinters.NewNoLintLint()). diff --git a/test/testdata/errname.go b/test/testdata/errname.go new file mode 100644 index 000000000000..280cc427ecc6 --- /dev/null +++ b/test/testdata/errname.go @@ -0,0 +1,55 @@ +//args: -Eerrname +package testdata + +import ( + "errors" + "fmt" +) + +var ( + EOF = errors.New("end of file") + ErrEndOfFile = errors.New("end of file") + errEndOfFile = errors.New("end of file") + + EndOfFileError = errors.New("end of file") // ERROR "the sentinel error `EndOfFileError` should be of the form ErrXxx" + ErrorEndOfFile = errors.New("end of file") // ERROR "the sentinel error `ErrorEndOfFile` should be of the form ErrXxx" + EndOfFileErr = errors.New("end of file") // ERROR "the sentinel error `EndOfFileErr` should be of the form ErrXxx" + endOfFileError = errors.New("end of file") // ERROR "the sentinel error `endOfFileError` should be of the form errXxx" + errorEndOfFile = errors.New("end of file") // ERROR "the sentinel error `errorEndOfFile` should be of the form errXxx" +) + +const maxSize = 256 + +var ( + ErrOutOfSize = fmt.Errorf("out of size (max %d)", maxSize) + errOutOfSize = fmt.Errorf("out of size (max %d)", maxSize) + + OutOfSizeError = fmt.Errorf("out of size (max %d)", maxSize) // ERROR "the sentinel error `OutOfSizeError` should be of the form ErrXxx" + outOfSizeError = fmt.Errorf("out of size (max %d)", maxSize) // ERROR "the sentinel error `outOfSizeError` should be of the form errXxx" +) + +func errInsideFuncIsNotSentinel() error { + var lastErr error + return lastErr +} + +type NotErrorType struct{} + +func (t NotErrorType) Set() {} +func (t NotErrorType) Get() {} + +type DNSConfigError struct{} + +func (D DNSConfigError) Error() string { return "DNS config error" } + +type someTypeWithoutPtr struct{} // ERROR "the error type `someTypeWithoutPtr` should be of the form xxxError" +func (s someTypeWithoutPtr) Error() string { return "someTypeWithoutPtr" } + +type SomeTypeWithoutPtr struct{} // ERROR "the error type `SomeTypeWithoutPtr` should be of the form XxxError" +func (s SomeTypeWithoutPtr) Error() string { return "SomeTypeWithoutPtr" } + +type someTypeWithPtr struct{} // ERROR "the error type `someTypeWithPtr` should be of the form xxxError" +func (s *someTypeWithPtr) Error() string { return "someTypeWithPtr" } + +type SomeTypeWithPtr struct{} // ERROR "the error type `SomeTypeWithPtr` should be of the form XxxError" +func (s *SomeTypeWithPtr) Error() string { return "SomeTypeWithPtr" } From f02df328709f806e5a6e98645ede5d41a842e0f8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=90=D0=BD=D1=82=D0=BE=D0=BD=20=D0=A2=D0=B5=D0=BB=D1=8B?= =?UTF-8?q?=D1=88=D0=B5=D0=B2?= Date: Tue, 3 Aug 2021 18:06:14 +0300 Subject: [PATCH 2/2] bump errname version --- go.mod | 2 +- go.sum | 2 ++ test/testdata/errname.go | 22 +++++++++++----------- 3 files changed, 14 insertions(+), 12 deletions(-) diff --git a/go.mod b/go.mod index 6943147215c8..edae540b97f4 100644 --- a/go.mod +++ b/go.mod @@ -4,7 +4,7 @@ go 1.15 require ( 4d63.com/gochecknoglobals v0.0.0-20201008074935-acfc0b28355a - github.com/Antonboom/errname v0.1.2 + github.com/Antonboom/errname v0.1.3 github.com/BurntSushi/toml v0.3.1 github.com/Djarvur/go-err113 v0.0.0-20210108212216-aea10b59be24 github.com/OpenPeeDeeP/depguard v1.0.1 diff --git a/go.sum b/go.sum index 97f88183e7e9..3580d16f8a33 100644 --- a/go.sum +++ b/go.sum @@ -46,6 +46,8 @@ contrib.go.opencensus.io/exporter/stackdriver v0.13.4/go.mod h1:aXENhDJ1Y4lIg4EU dmitri.shuralyov.com/gpu/mtl v0.0.0-20190408044501-666a987793e9/go.mod h1:H6x//7gZCb22OMCxBHrMx7a5I7Hp++hsVxbQ4BYO7hU= github.com/Antonboom/errname v0.1.2 h1:Lg1R0kXPC57BhcK8P8dDjMC4xee7BBBwVxe9M0yOF2A= github.com/Antonboom/errname v0.1.2/go.mod h1:jRXo3m0E0EuCnK3wbsSVH3X55Z4iTDLl6ZfCxwFj4TM= +github.com/Antonboom/errname v0.1.3 h1:qKV8gSzPzBqrG/q0dgraZXJCymWt6KuD9+Y7K7xtzN8= +github.com/Antonboom/errname v0.1.3/go.mod h1:jRXo3m0E0EuCnK3wbsSVH3X55Z4iTDLl6ZfCxwFj4TM= github.com/BurntSushi/toml v0.3.1 h1:WXkYYl6Yr3qBf1K79EBnL4mak0OimBfB0XUf9Vl28OQ= github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU= github.com/BurntSushi/xgb v0.0.0-20160522181843-27f122750802/go.mod h1:IVnqGOEym/WlBOVXweHU+Q+/VP0lqqI8lqeDx9IjBqo= diff --git a/test/testdata/errname.go b/test/testdata/errname.go index 280cc427ecc6..8b44e0b78f56 100644 --- a/test/testdata/errname.go +++ b/test/testdata/errname.go @@ -11,11 +11,11 @@ var ( ErrEndOfFile = errors.New("end of file") errEndOfFile = errors.New("end of file") - EndOfFileError = errors.New("end of file") // ERROR "the sentinel error `EndOfFileError` should be of the form ErrXxx" - ErrorEndOfFile = errors.New("end of file") // ERROR "the sentinel error `ErrorEndOfFile` should be of the form ErrXxx" - EndOfFileErr = errors.New("end of file") // ERROR "the sentinel error `EndOfFileErr` should be of the form ErrXxx" - endOfFileError = errors.New("end of file") // ERROR "the sentinel error `endOfFileError` should be of the form errXxx" - errorEndOfFile = errors.New("end of file") // ERROR "the sentinel error `errorEndOfFile` should be of the form errXxx" + EndOfFileError = errors.New("end of file") // ERROR "the variable name `EndOfFileError` should conform to the `ErrXxx` format" + ErrorEndOfFile = errors.New("end of file") // ERROR "the variable name `ErrorEndOfFile` should conform to the `ErrXxx` format" + EndOfFileErr = errors.New("end of file") // ERROR "the variable name `EndOfFileErr` should conform to the `ErrXxx` format" + endOfFileError = errors.New("end of file") // ERROR "the variable name `endOfFileError` should conform to the `errXxx` format" + errorEndOfFile = errors.New("end of file") // ERROR "the variable name `errorEndOfFile` should conform to the `errXxx` format" ) const maxSize = 256 @@ -24,8 +24,8 @@ var ( ErrOutOfSize = fmt.Errorf("out of size (max %d)", maxSize) errOutOfSize = fmt.Errorf("out of size (max %d)", maxSize) - OutOfSizeError = fmt.Errorf("out of size (max %d)", maxSize) // ERROR "the sentinel error `OutOfSizeError` should be of the form ErrXxx" - outOfSizeError = fmt.Errorf("out of size (max %d)", maxSize) // ERROR "the sentinel error `outOfSizeError` should be of the form errXxx" + OutOfSizeError = fmt.Errorf("out of size (max %d)", maxSize) // ERROR "the variable name `OutOfSizeError` should conform to the `ErrXxx` format" + outOfSizeError = fmt.Errorf("out of size (max %d)", maxSize) // ERROR "the variable name `outOfSizeError` should conform to the `errXxx` format" ) func errInsideFuncIsNotSentinel() error { @@ -42,14 +42,14 @@ type DNSConfigError struct{} func (D DNSConfigError) Error() string { return "DNS config error" } -type someTypeWithoutPtr struct{} // ERROR "the error type `someTypeWithoutPtr` should be of the form xxxError" +type someTypeWithoutPtr struct{} // ERROR "the type name `someTypeWithoutPtr` should conform to the `xxxError` format" func (s someTypeWithoutPtr) Error() string { return "someTypeWithoutPtr" } -type SomeTypeWithoutPtr struct{} // ERROR "the error type `SomeTypeWithoutPtr` should be of the form XxxError" +type SomeTypeWithoutPtr struct{} // ERROR "the type name `SomeTypeWithoutPtr` should conform to the `XxxError` format" func (s SomeTypeWithoutPtr) Error() string { return "SomeTypeWithoutPtr" } -type someTypeWithPtr struct{} // ERROR "the error type `someTypeWithPtr` should be of the form xxxError" +type someTypeWithPtr struct{} // ERROR "the type name `someTypeWithPtr` should conform to the `xxxError` format" func (s *someTypeWithPtr) Error() string { return "someTypeWithPtr" } -type SomeTypeWithPtr struct{} // ERROR "the error type `SomeTypeWithPtr` should be of the form XxxError" +type SomeTypeWithPtr struct{} // ERROR "the type name `SomeTypeWithPtr` should conform to the `XxxError` format" func (s *SomeTypeWithPtr) Error() string { return "SomeTypeWithPtr" }