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

Enable a few more golangci-lint linters #3546

Merged
merged 1 commit into from
Aug 25, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -119,8 +119,7 @@ jobs:
- uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744 # v3
- uses: golangci/golangci-lint-action@3a919529898de77ec3da873e3063ca4b10e7f5cc # v3
with:
version: v1.52.2
args: --enable goimports
version: v1.54.2
fuzz:
runs-on: ubuntu-latest
steps:
Expand Down
2 changes: 1 addition & 1 deletion protoc-gen-openapiv2/internal/genopenapi/generator_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1685,7 +1685,7 @@ func TestFindExpectedPaths(t *testing.T) {
for _, tc := range testCases {
tc := tc

t.Run(string(tc.testName), func(t *testing.T) {
t.Run(tc.testName, func(t *testing.T) {
t.Parallel()

foundPaths := []string{}
Expand Down
1 change: 1 addition & 0 deletions protoc-gen-openapiv2/internal/genopenapi/helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ func getUniqueFields(schemaFieldsRequired []string, fieldsRequired []string) []s
for j, schemaFieldRequired := range schemaFieldsRequired {
index = nil
for i, fieldRequired := range fieldsRequired {
i := i
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This wasn't technically required in this case (because of the break call), however in general it is good practice to avoid these sorts of issues.

if schemaFieldRequired == fieldRequired {
index = &i
break
Expand Down
15 changes: 7 additions & 8 deletions protoc-gen-openapiv2/internal/genopenapi/template.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package genopenapi

import (
"bytes"
"encoding/json"
"errors"
"fmt"
"math"
Expand Down Expand Up @@ -980,9 +979,9 @@ pathLoop:
buffer += string(char)
if reg.GetUseJSONNamesForFields() &&
len(jsonBuffer) > 1 {
jsonSnakeCaseName := string(jsonBuffer[1:])
jsonCamelCaseName := string(lowerCamelCase(jsonSnakeCaseName, fields, msgs))
prev := string(buffer[:len(buffer)-len(jsonSnakeCaseName)-2])
jsonSnakeCaseName := jsonBuffer[1:]
jsonCamelCaseName := lowerCamelCase(jsonSnakeCaseName, fields, msgs)
prev := buffer[:len(buffer)-len(jsonSnakeCaseName)-2]
buffer = strings.Join([]string{prev, "{", jsonCamelCaseName, "}"}, "")
jsonBuffer = ""
}
Expand Down Expand Up @@ -1342,6 +1341,7 @@ func renderServices(services []*descriptor.Service, paths *openapiPathsObject, r
var firstPathParameter *openapiParameterObject
var firstParamIndex int
for index, param := range parameters {
param := param
if param.In == "path" {
firstPathParameter = &param
firstParamIndex = index
Expand Down Expand Up @@ -2036,7 +2036,7 @@ func processExtensions(inputExts map[string]*structpb.Value) ([]extension, error
if err != nil {
return nil, err
}
exts = append(exts, extension{key: k, value: json.RawMessage(ext)})
exts = append(exts, extension{key: k, value: ext})
}
sort.Slice(exts, func(i, j int) bool { return exts[i].key < exts[j].key })
return exts, nil
Expand Down Expand Up @@ -2502,11 +2502,10 @@ func protoPathIndex(descriptorType reflect.Type, what string) int32 {
if pbtag == "" {
panic(fmt.Errorf("no Go tag 'protobuf' on protobuf descriptor for %s", what))
}
path, err := strconv.Atoi(strings.Split(pbtag, ",")[1])
path, err := strconv.ParseInt(strings.Split(pbtag, ",")[1], 10, 32)
if err != nil {
panic(fmt.Errorf("protobuf descriptor id for %s cannot be converted to a number: %s", what, err.Error()))
}

return int32(path)
}

Expand Down Expand Up @@ -3013,7 +3012,7 @@ func lowerCamelCase(fieldName string, fields []*descriptor.Field, msgs []*descri
fieldNames := strings.Split(fieldName, ".")
fieldNamesWithCamelCase := make([]string, 0)
for i := 0; i < len(fieldNames)-1; i++ {
fieldNamesWithCamelCase = append(fieldNamesWithCamelCase, casing.JSONCamelCase(string(fieldNames[i])))
fieldNamesWithCamelCase = append(fieldNamesWithCamelCase, casing.JSONCamelCase(fieldNames[i]))
}
prefix := strings.Join(fieldNamesWithCamelCase, ".")
reservedJSONName := getReservedJSONName(fieldName, messageNameToFieldsToJSONName, fieldNameToType)
Expand Down
11 changes: 6 additions & 5 deletions protoc-gen-openapiv2/internal/genopenapi/template_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3537,6 +3537,7 @@ func TestApplyTemplateRequestWithBodyQueryParameters(t *testing.T) {
}

for _, tt := range tests {
tt := tt
t.Run(tt.name, func(t *testing.T) {
reg := descriptor.NewRegistry()
if err := AddErrorDefs(reg); err != nil {
Expand Down Expand Up @@ -3802,8 +3803,8 @@ func TestApplyTemplateProtobufAny(t *testing.T) {

func generateFieldsForJSONReservedName() []*descriptor.Field {
fields := make([]*descriptor.Field, 0)
fieldName := string("json_name")
fieldJSONName := string("jsonNAME")
fieldName := "json_name"
fieldJSONName := "jsonNAME"
fieldDescriptor := descriptorpb.FieldDescriptorProto{Name: &fieldName, JsonName: &fieldJSONName}
field := &descriptor.Field{FieldDescriptorProto: &fieldDescriptor}
return append(fields, field)
Expand Down Expand Up @@ -9906,7 +9907,7 @@ func TestGetPathItemObjectSwaggerObjectMethod(t *testing.T) {
for _, tc := range testCases {
tc := tc

t.Run(string(tc.testName), func(t *testing.T) {
t.Run(tc.testName, func(t *testing.T) {
actualPathItemObject := tc.swaggerObject.getPathItemObject(tc.path)
if isEqual := reflect.DeepEqual(actualPathItemObject, tc.expectedPathItemObject); !isEqual {
t.Fatalf("Got pathItemObject: %#v, want pathItemObject: %#v", actualPathItemObject, tc.expectedPathItemObject)
Expand Down Expand Up @@ -9989,7 +9990,7 @@ func TestGetPathItemObjectFunction(t *testing.T) {
for _, tc := range testCases {
tc := tc

t.Run(string(tc.testName), func(t *testing.T) {
t.Run(tc.testName, func(t *testing.T) {
actualPathItemObject, actualIsPathPresent := getPathItemObject(tc.paths, tc.path)
if isEqual := reflect.DeepEqual(actualPathItemObject, tc.expectedPathItemObject); !isEqual {
t.Fatalf("Got pathItemObject: %#v, want pathItemObject: %#v", actualPathItemObject, tc.expectedPathItemObject)
Expand Down Expand Up @@ -10087,7 +10088,7 @@ func TestUpdatePaths(t *testing.T) {
for _, tc := range testCases {
tc := tc

t.Run(string(tc.testName), func(t *testing.T) {
t.Run(tc.testName, func(t *testing.T) {
updatePaths(&tc.paths, tc.pathToUpdate, tc.newPathItemObject)
if pathsCorrectlyUpdated := reflect.DeepEqual(tc.paths, tc.expectedUpdatedPaths); !pathsCorrectlyUpdated {
t.Fatalf("Paths not correctly updated. Want %#v, got %#v", tc.expectedUpdatedPaths, tc.paths)
Expand Down
2 changes: 1 addition & 1 deletion protoc-gen-openapiv2/internal/genopenapi/types_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ func TestRawExample(t *testing.T) {
t.Run(string(tc.In), func(t *testing.T) {
t.Parallel()

ex := RawExample(tc.In)
ex := tc.In

out, err := yaml.Marshal(ex)
switch {
Expand Down
54 changes: 28 additions & 26 deletions runtime/context_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@ func TestAnnotateContext_WorksWithEmpty(t *testing.T) {
ctx := context.Background()
expectedRPCName := "/example.Example/Example"
expectedHTTPPathPattern := "/v1"
request, err := http.NewRequest("GET", "http://www.example.com/v1", nil)
request, err := http.NewRequestWithContext(ctx, "GET", "http://www.example.com/v1", nil)
if err != nil {
t.Fatalf("http.NewRequest(%q, %q, nil) failed with %v; want success", "GET", "http://www.example.com", err)
t.Fatalf("http.NewRequestWithContext(ctx, %q, %q, nil) failed with %v; want success", "GET", "http://www.example.com", err)
}
request.Header.Add("Some-Irrelevant-Header", "some value")
annotated, err := runtime.AnnotateContext(ctx, runtime.NewServeMux(), request, expectedRPCName, runtime.WithHTTPPathPattern(expectedHTTPPathPattern))
Expand All @@ -40,9 +40,9 @@ func TestAnnotateContext_ForwardsGrpcMetadata(t *testing.T) {
ctx := context.Background()
expectedRPCName := "/example.Example/Example"
expectedHTTPPathPattern := "/v1"
request, err := http.NewRequest("GET", "http://www.example.com/v1", nil)
request, err := http.NewRequestWithContext(ctx, "GET", "http://www.example.com/v1", nil)
if err != nil {
t.Fatalf("http.NewRequest(%q, %q, nil) failed with %v; want success", "GET", "http://www.example.com", err)
t.Fatalf("http.NewRequestWithContext(ctx, %q, %q, nil) failed with %v; want success", "GET", "http://www.example.com", err)
}
request.Header.Add("Some-Irrelevant-Header", "some value")
request.Header.Add("Grpc-Metadata-FooBar", "Value1")
Expand Down Expand Up @@ -86,9 +86,9 @@ func TestAnnotateContext_ForwardsGrpcMetadata(t *testing.T) {
func TestAnnotateContext_ForwardGrpcBinaryMetadata(t *testing.T) {
ctx := context.Background()
expectedRPCName := "/example.Example/Example"
request, err := http.NewRequest("GET", "http://www.example.com", nil)
request, err := http.NewRequestWithContext(ctx, "GET", "http://www.example.com", nil)
if err != nil {
t.Fatalf("http.NewRequest(%q, %q, nil) failed with %v; want success", "GET", "http://www.example.com", err)
t.Fatalf("http.NewRequestWithContext(ctx, %q, %q, nil) failed with %v; want success", "GET", "http://www.example.com", err)
}

binData := []byte("\x00test-binary-data")
Expand Down Expand Up @@ -116,9 +116,9 @@ func TestAnnotateContext_ForwardGrpcBinaryMetadata(t *testing.T) {
func TestAnnotateContext_XForwardedFor(t *testing.T) {
ctx := context.Background()
expectedRPCName := "/example.Example/Example"
request, err := http.NewRequest("GET", "http://bar.foo.example.com", nil)
request, err := http.NewRequestWithContext(ctx, "GET", "http://bar.foo.example.com", nil)
if err != nil {
t.Fatalf("http.NewRequest(%q, %q, nil) failed with %v; want success", "GET", "http://bar.foo.example.com", err)
t.Fatalf("http.NewRequestWithContext(ctx, %q, %q, nil) failed with %v; want success", "GET", "http://bar.foo.example.com", err)
}
request.Header.Add("X-Forwarded-For", "192.0.2.100") // client
request.RemoteAddr = "192.0.2.200:12345" // proxy
Expand Down Expand Up @@ -149,9 +149,9 @@ func TestAnnotateContext_XForwardedFor(t *testing.T) {
func TestAnnotateContext_SupportsTimeouts(t *testing.T) {
ctx := context.Background()
expectedRPCName := "/example.Example/Example"
request, err := http.NewRequest("GET", "http://example.com", nil)
request, err := http.NewRequestWithContext(ctx, "GET", "http://example.com", nil)
if err != nil {
t.Fatalf(`http.NewRequest("GET", "http://example.com", nil failed with %v; want success`, err)
t.Fatalf(`http.NewRequestWithContext(ctx, "GET", "http://example.com", nil) failed with %v; want success`, err)
}
annotated, err := runtime.AnnotateContext(ctx, runtime.NewServeMux(), request, expectedRPCName)
if err != nil {
Expand Down Expand Up @@ -228,15 +228,16 @@ func TestAnnotateContext_SupportsTimeouts(t *testing.T) {
}
}
func TestAnnotateContext_SupportsCustomAnnotators(t *testing.T) {
ctx := context.Background()
md1 := func(context.Context, *http.Request) metadata.MD { return metadata.New(map[string]string{"foo": "bar"}) }
md2 := func(context.Context, *http.Request) metadata.MD { return metadata.New(map[string]string{"baz": "qux"}) }
expected := metadata.New(map[string]string{"foo": "bar", "baz": "qux"})
expectedRPCName := "/example.Example/Example"
request, err := http.NewRequest("GET", "http://example.com", nil)
request, err := http.NewRequestWithContext(ctx, "GET", "http://example.com", nil)
if err != nil {
t.Fatalf(`http.NewRequest("GET", "http://example.com", nil failed with %v; want success`, err)
t.Fatalf(`http.NewRequestWithContext(ctx, "GET", "http://example.com", nil) failed with %v; want success`, err)
}
annotated, err := runtime.AnnotateContext(context.Background(), runtime.NewServeMux(runtime.WithMetadata(md1), runtime.WithMetadata(md2)), request, expectedRPCName)
annotated, err := runtime.AnnotateContext(ctx, runtime.NewServeMux(runtime.WithMetadata(md1), runtime.WithMetadata(md2)), request, expectedRPCName)
if err != nil {
t.Errorf("runtime.AnnotateContext(ctx, %#v) failed with %v; want success", request, err)
return
Expand All @@ -258,9 +259,9 @@ func TestAnnotateIncomingContext_WorksWithEmpty(t *testing.T) {
ctx := context.Background()
expectedRPCName := "/example.Example/Example"
expectedHTTPPathPattern := "/v1"
request, err := http.NewRequest("GET", "http://www.example.com/v1", nil)
request, err := http.NewRequestWithContext(ctx, "GET", "http://www.example.com/v1", nil)
if err != nil {
t.Fatalf("http.NewRequest(%q, %q, nil) failed with %v; want success", "GET", "http://www.example.com", err)
t.Fatalf("http.NewRequestWithContext(ctx, %q, %q, nil) failed with %v; want success", "GET", "http://www.example.com", err)
}
request.Header.Add("Some-Irrelevant-Header", "some value")
annotated, err := runtime.AnnotateIncomingContext(ctx, runtime.NewServeMux(), request, expectedRPCName, runtime.WithHTTPPathPattern(expectedHTTPPathPattern))
Expand All @@ -283,9 +284,9 @@ func TestAnnotateIncomingContext_ForwardsGrpcMetadata(t *testing.T) {
ctx := context.Background()
expectedRPCName := "/example.Example/Example"
expectedHTTPPathPattern := "/v1"
request, err := http.NewRequest("GET", "http://www.example.com/v1", nil)
request, err := http.NewRequestWithContext(ctx, "GET", "http://www.example.com/v1", nil)
if err != nil {
t.Fatalf("http.NewRequest(%q, %q, nil) failed with %v; want success", "GET", "http://www.example.com", err)
t.Fatalf("http.NewRequestWithContext(ctx, %q, %q, nil) failed with %v; want success", "GET", "http://www.example.com", err)
}
request.Header.Add("Some-Irrelevant-Header", "some value")
request.Header.Add("Grpc-Metadata-FooBar", "Value1")
Expand Down Expand Up @@ -328,9 +329,9 @@ func TestAnnotateIncomingContext_ForwardsGrpcMetadata(t *testing.T) {
func TestAnnotateIncomingContext_ForwardGrpcBinaryMetadata(t *testing.T) {
ctx := context.Background()
expectedRPCName := "/example.Example/Example"
request, err := http.NewRequest("GET", "http://www.example.com", nil)
request, err := http.NewRequestWithContext(ctx, "GET", "http://www.example.com", nil)
if err != nil {
t.Fatalf("http.NewRequest(%q, %q, nil) failed with %v; want success", "GET", "http://www.example.com", err)
t.Fatalf("http.NewRequestWithContext(ctx, %q, %q, nil) failed with %v; want success", "GET", "http://www.example.com", err)
}

binData := []byte("\x00test-binary-data")
Expand Down Expand Up @@ -358,9 +359,9 @@ func TestAnnotateIncomingContext_ForwardGrpcBinaryMetadata(t *testing.T) {
func TestAnnotateIncomingContext_XForwardedFor(t *testing.T) {
ctx := context.Background()
expectedRPCName := "/example.Example/Example"
request, err := http.NewRequest("GET", "http://bar.foo.example.com", nil)
request, err := http.NewRequestWithContext(ctx, "GET", "http://bar.foo.example.com", nil)
if err != nil {
t.Fatalf("http.NewRequest(%q, %q, nil) failed with %v; want success", "GET", "http://bar.foo.example.com", err)
t.Fatalf("http.NewRequestWithContext(ctx, %q, %q, nil) failed with %v; want success", "GET", "http://bar.foo.example.com", err)
}
request.Header.Add("X-Forwarded-For", "192.0.2.100") // client
request.RemoteAddr = "192.0.2.200:12345" // proxy
Expand Down Expand Up @@ -393,9 +394,9 @@ func TestAnnotateIncomingContext_SupportsTimeouts(t *testing.T) {
runtime.DefaultContextTimeout = 0 * time.Second
expectedRPCName := "/example.Example/Example"
ctx := context.Background()
request, err := http.NewRequest("GET", "http://example.com", nil)
request, err := http.NewRequestWithContext(ctx, "GET", "http://example.com", nil)
if err != nil {
t.Fatalf(`http.NewRequest("GET", "http://example.com", nil failed with %v; want success`, err)
t.Fatalf(`http.NewRequestWithContext(ctx, "GET", "http://example.com", nil) failed with %v; want success`, err)
}
annotated, err := runtime.AnnotateIncomingContext(ctx, runtime.NewServeMux(), request, expectedRPCName)
if err != nil {
Expand Down Expand Up @@ -472,15 +473,16 @@ func TestAnnotateIncomingContext_SupportsTimeouts(t *testing.T) {
}
}
func TestAnnotateIncomingContext_SupportsCustomAnnotators(t *testing.T) {
ctx := context.Background()
md1 := func(context.Context, *http.Request) metadata.MD { return metadata.New(map[string]string{"foo": "bar"}) }
md2 := func(context.Context, *http.Request) metadata.MD { return metadata.New(map[string]string{"baz": "qux"}) }
expected := metadata.New(map[string]string{"foo": "bar", "baz": "qux"})
expectedRPCName := "/example.Example/Example"
request, err := http.NewRequest("GET", "http://example.com", nil)
request, err := http.NewRequestWithContext(ctx, "GET", "http://example.com", nil)
if err != nil {
t.Fatalf(`http.NewRequest("GET", "http://example.com", nil failed with %v; want success`, err)
t.Fatalf(`http.NewRequestWithContext(ctx, "GET", "http://example.com", nil) failed with %v; want success`, err)
}
annotated, err := runtime.AnnotateIncomingContext(context.Background(), runtime.NewServeMux(runtime.WithMetadata(md1), runtime.WithMetadata(md2)), request, expectedRPCName)
annotated, err := runtime.AnnotateIncomingContext(ctx, runtime.NewServeMux(runtime.WithMetadata(md1), runtime.WithMetadata(md2)), request, expectedRPCName)
if err != nil {
t.Errorf("runtime.AnnotateIncomingContext(ctx, %#v) failed with %v; want success", request, err)
return
Expand Down
2 changes: 1 addition & 1 deletion runtime/errors_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ func TestDefaultHTTPError(t *testing.T) {
} {
t.Run(strconv.Itoa(i), func(t *testing.T) {
w := httptest.NewRecorder()
req, _ := http.NewRequest("", "", nil) // Pass in an empty request to match the signature
req, _ := http.NewRequestWithContext(ctx, "", "", nil) // Pass in an empty request to match the signature
mux := runtime.NewServeMux()
marshaler := &runtime.JSONPb{}
runtime.HTTPError(ctx, mux, marshaler, w, req, spec.err)
Expand Down
2 changes: 1 addition & 1 deletion runtime/fieldmask.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ func FieldMaskFromRequestBody(r io.Reader, msg proto.Message) (*field_mask.Field
var root interface{}

if err := json.NewDecoder(r).Decode(&root); err != nil {
if err == io.EOF {
if errors.Is(err, io.EOF) {
return fm, nil
}
return nil, err
Expand Down
3 changes: 2 additions & 1 deletion runtime/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package runtime

import (
"context"
"errors"
"fmt"
"io"
"net/http"
Expand Down Expand Up @@ -48,7 +49,7 @@ func ForwardResponseStream(ctx context.Context, mux *ServeMux, marshaler Marshal
var wroteHeader bool
for {
resp, err := recv()
if err == io.EOF {
if errors.Is(err, io.EOF) {
return
}
if err != nil {
Expand Down
4 changes: 3 additions & 1 deletion runtime/marshaler_registry_test.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package runtime_test

import (
"context"
"errors"
"fmt"
"io"
Expand All @@ -11,7 +12,8 @@ import (
)

func TestMarshalerForRequest(t *testing.T) {
r, err := http.NewRequest("GET", "http://example.com", nil)
ctx := context.Background()
r, err := http.NewRequestWithContext(ctx, "GET", "http://example.com", nil)
if err != nil {
t.Fatalf(`http.NewRequest("GET", "http://example.com", nil) failed with %v; want success`, err)
}
Expand Down
3 changes: 2 additions & 1 deletion runtime/mux_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -584,7 +584,8 @@ func TestMuxServeHTTP(t *testing.T) {
}

reqUrl := fmt.Sprintf("https://host.example%s", spec.reqPath)
r, err := http.NewRequest(spec.reqMethod, reqUrl, bytes.NewReader(nil))
ctx := context.Background()
r, err := http.NewRequestWithContext(ctx, spec.reqMethod, reqUrl, bytes.NewReader(nil))
if err != nil {
t.Fatalf("http.NewRequest(%q, %q, nil) failed with %v; want success", spec.reqMethod, reqUrl, err)
}
Expand Down
7 changes: 4 additions & 3 deletions runtime/pattern_test.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package runtime

import (
"errors"
"fmt"
"reflect"
"strings"
Expand Down Expand Up @@ -181,7 +182,7 @@ func TestNewPatternWithWrongOp(t *testing.T) {
t.Errorf("NewPattern(%d, %v, %q, %q) succeeded; want failure with %v", validVersion, spec.ops, spec.pool, spec.verb, ErrInvalidPattern)
continue
}
if err != ErrInvalidPattern {
if !errors.Is(err, ErrInvalidPattern) {
t.Errorf("NewPattern(%d, %v, %q, %q) failed with %v; want failure with %v", validVersion, spec.ops, spec.pool, spec.verb, err, ErrInvalidPattern)
continue
}
Expand All @@ -207,7 +208,7 @@ func TestNewPatternWithStackUnderflow(t *testing.T) {
t.Errorf("NewPattern(%d, %v, %q, %q) succeeded; want failure with %v", validVersion, spec.ops, spec.pool, spec.verb, ErrInvalidPattern)
continue
}
if err != ErrInvalidPattern {
if !errors.Is(err, ErrInvalidPattern) {
t.Errorf("NewPattern(%d, %v, %q, %q) failed with %v; want failure with %v", validVersion, spec.ops, spec.pool, spec.verb, err, ErrInvalidPattern)
continue
}
Expand Down Expand Up @@ -354,7 +355,7 @@ func TestMatch(t *testing.T) {
t.Errorf("pat.Match(%q) succeeded; want failure with %v; pattern = (%v, %q)", path, ErrNotMatch, spec.ops, spec.pool)
continue
}
if err != ErrNotMatch {
if !errors.Is(err, ErrNotMatch) {
t.Errorf("pat.Match(%q) failed with %v; want failure with %v; pattern = (%v, %q)", spec.notMatch, err, ErrNotMatch, spec.ops, spec.pool)
}
}
Expand Down
Loading