diff --git a/codegen/example/templates/client_endpoint_init.go.tpl b/codegen/example/templates/client_endpoint_init.go.tpl index c98f4fe2ae..ad66d773f2 100644 --- a/codegen/example/templates/client_endpoint_init.go.tpl +++ b/codegen/example/templates/client_endpoint_init.go.tpl @@ -16,7 +16,7 @@ } } if err != nil { - if err == flag.ErrHelp { + if errors.Is(err, flag.ErrHelp) { os.Exit(0) } fmt.Fprintln(os.Stderr, err.Error()) diff --git a/codegen/example/testdata/client-no-server.golden b/codegen/example/testdata/client-no-server.golden index 5e2034ff52..7a8e26f2f6 100644 --- a/codegen/example/testdata/client-no-server.golden +++ b/codegen/example/testdata/client-no-server.golden @@ -61,7 +61,7 @@ func main() { } } if err != nil { - if err == flag.ErrHelp { + if errors.Is(err, flag.ErrHelp) { os.Exit(0) } fmt.Fprintln(os.Stderr, err.Error()) diff --git a/codegen/example/testdata/client-single-server-multiple-hosts-with-variables.golden b/codegen/example/testdata/client-single-server-multiple-hosts-with-variables.golden index 192f4c0df5..93a88d092f 100644 --- a/codegen/example/testdata/client-single-server-multiple-hosts-with-variables.golden +++ b/codegen/example/testdata/client-single-server-multiple-hosts-with-variables.golden @@ -80,7 +80,7 @@ func main() { } } if err != nil { - if err == flag.ErrHelp { + if errors.Is(err, flag.ErrHelp) { os.Exit(0) } fmt.Fprintln(os.Stderr, err.Error()) diff --git a/codegen/example/testdata/client-single-server-multiple-hosts.golden b/codegen/example/testdata/client-single-server-multiple-hosts.golden index 93626da660..3b29365051 100644 --- a/codegen/example/testdata/client-single-server-multiple-hosts.golden +++ b/codegen/example/testdata/client-single-server-multiple-hosts.golden @@ -61,7 +61,7 @@ func main() { } } if err != nil { - if err == flag.ErrHelp { + if errors.Is(err, flag.ErrHelp) { os.Exit(0) } fmt.Fprintln(os.Stderr, err.Error()) diff --git a/codegen/example/testdata/client-single-server-single-host-with-variables.golden b/codegen/example/testdata/client-single-server-single-host-with-variables.golden index 247561c881..4da702614a 100644 --- a/codegen/example/testdata/client-single-server-single-host-with-variables.golden +++ b/codegen/example/testdata/client-single-server-single-host-with-variables.golden @@ -77,7 +77,7 @@ func main() { } } if err != nil { - if err == flag.ErrHelp { + if errors.Is(err, flag.ErrHelp) { os.Exit(0) } fmt.Fprintln(os.Stderr, err.Error()) diff --git a/codegen/example/testdata/client-single-server-single-host.golden b/codegen/example/testdata/client-single-server-single-host.golden index 6acfbeca53..253e4ef805 100644 --- a/codegen/example/testdata/client-single-server-single-host.golden +++ b/codegen/example/testdata/client-single-server-single-host.golden @@ -61,7 +61,7 @@ func main() { } } if err != nil { - if err == flag.ErrHelp { + if errors.Is(err, flag.ErrHelp) { os.Exit(0) } fmt.Fprintln(os.Stderr, err.Error()) diff --git a/http/codegen/templates/client_sse.go.tpl b/http/codegen/templates/client_sse.go.tpl index e767c433ee..d35e142e11 100644 --- a/http/codegen/templates/client_sse.go.tpl +++ b/http/codegen/templates/client_sse.go.tpl @@ -29,10 +29,10 @@ func (s *{{ .Method.VarName }}StreamImpl) RecvWithContext(ctx context.Context) ( var byts []byte byts, err = s.readEvent(ctx) if err != nil { - if err == io.EOF || err == context.Canceled || err == context.DeadlineExceeded { + if errors.Is(err, io.EOF) || errors.Is(err, context.Canceled) || errors.Is(err, context.DeadlineExceeded) { // Clean up on EOF or context cancellation s.Close() - if err == io.EOF { + if errors.Is(err, io.EOF) { err = nil } } @@ -117,7 +117,7 @@ func (s *{{ .Method.VarName }}StreamImpl) readEvent(ctx context.Context) ([]byte } // Return partial data at EOF - if err == io.EOF { + if errors.Is(err, io.EOF) { if len(eventData) > 0 { return eventData, nil } diff --git a/http/codegen/templates/partial/request_elements.go.tpl b/http/codegen/templates/partial/request_elements.go.tpl index 37615baaec..7b2c88f79f 100644 --- a/http/codegen/templates/partial/request_elements.go.tpl +++ b/http/codegen/templates/partial/request_elements.go.tpl @@ -296,7 +296,7 @@ qp := r.URL.Query() {{- range .Cookies }} c, {{ if not .Required }}_{{ else }}err{{ end }} = r.Cookie("{{ .HTTPName }}") {{- if and (or (eq .Type.Name "string") (eq .Type.Name "any")) .Required }} - if err == http.ErrNoCookie { + if errors.Is(err, http.ErrNoCookie) { err = goa.MergeErrors(err, goa.MissingFieldError("{{ .Name }}", "cookie")) } else { {{ .VarName }} = c.Value diff --git a/http/codegen/templates/request_decoder.go.tpl b/http/codegen/templates/request_decoder.go.tpl index 01136ccda7..0de0e497da 100644 --- a/http/codegen/templates/request_decoder.go.tpl +++ b/http/codegen/templates/request_decoder.go.tpl @@ -18,11 +18,11 @@ func {{ .RequestDecoder }}(mux goahttp.Muxer, decoder func(*http.Request) goahtt err = decoder(r).Decode(&body) if err != nil { {{- if .Payload.Request.MustHaveBody }} - if err == io.EOF { + if errors.Is(err, io.EOF) { return nil, goa.MissingPayloadError() } {{- else }} - if err == io.EOF { + if errors.Is(err, io.EOF) { err = nil } else { {{- end }} diff --git a/http/codegen/testdata/payload_decode_functions.go b/http/codegen/testdata/payload_decode_functions.go index cc97eddc2e..605a2cc1a5 100644 --- a/http/codegen/testdata/payload_decode_functions.go +++ b/http/codegen/testdata/payload_decode_functions.go @@ -3575,7 +3575,7 @@ func DecodeMethodCookiePrimitiveStringValidateRequest(mux goahttp.Muxer, decoder c *http.Cookie ) c, err = r.Cookie("c") - if err == http.ErrNoCookie { + if errors.Is(err, http.ErrNoCookie) { err = goa.MergeErrors(err, goa.MissingFieldError("c", "cookie")) } else { c2 = c.Value @@ -3700,7 +3700,7 @@ func DecodeMethodCookiePrimitiveStringDefaultRequest(mux goahttp.Muxer, decoder c *http.Cookie ) c, err = r.Cookie("c") - if err == http.ErrNoCookie { + if errors.Is(err, http.ErrNoCookie) { err = goa.MergeErrors(err, goa.MissingFieldError("c", "cookie")) } else { c2 = c.Value @@ -3725,7 +3725,7 @@ func DecodeMethodBodyStringRequest(mux goahttp.Muxer, decoder func(*http.Request ) err = decoder(r).Decode(&body) if err != nil { - if err == io.EOF { + if errors.Is(err, io.EOF) { return nil, goa.MissingPayloadError() } var gerr *goa.ServiceError @@ -3751,7 +3751,7 @@ func DecodeMethodBodyStringValidateRequest(mux goahttp.Muxer, decoder func(*http ) err = decoder(r).Decode(&body) if err != nil { - if err == io.EOF { + if errors.Is(err, io.EOF) { return nil, goa.MissingPayloadError() } var gerr *goa.ServiceError @@ -3781,7 +3781,7 @@ func DecodeMethodBodyUserRequest(mux goahttp.Muxer, decoder func(*http.Request) ) err = decoder(r).Decode(&body) if err != nil { - if err == io.EOF { + if errors.Is(err, io.EOF) { return nil, goa.MissingPayloadError() } var gerr *goa.ServiceError @@ -3807,7 +3807,7 @@ func DecodeMethodBodyUserRequest(mux goahttp.Muxer, decoder func(*http.Request) ) err = decoder(r).Decode(&body) if err != nil { - if err == io.EOF { + if errors.Is(err, io.EOF) { return nil, goa.MissingPayloadError() } var gerr *goa.ServiceError @@ -3837,7 +3837,7 @@ func DecodeMethodBodyUserRequest(mux goahttp.Muxer, decoder func(*http.Request) ) err = decoder(r).Decode(&body) if err != nil { - if err == io.EOF { + if errors.Is(err, io.EOF) { err = nil } else { var gerr *goa.ServiceError @@ -3868,7 +3868,7 @@ func DecodeMethodBodyUserValidateRequest(mux goahttp.Muxer, decoder func(*http.R ) err = decoder(r).Decode(&body) if err != nil { - if err == io.EOF { + if errors.Is(err, io.EOF) { err = nil } else { var gerr *goa.ServiceError @@ -3901,7 +3901,7 @@ func DecodeMethodBodyObjectRequest(mux goahttp.Muxer, decoder func(*http.Request ) err = decoder(r).Decode(&body) if err != nil { - if err == io.EOF { + if errors.Is(err, io.EOF) { return nil, goa.MissingPayloadError() } var gerr *goa.ServiceError @@ -3929,7 +3929,7 @@ func DecodeMethodBodyObjectRequiredRequest(mux goahttp.Muxer, decoder func(*http ) err = decoder(r).Decode(&body) if err != nil { - if err == io.EOF { + if errors.Is(err, io.EOF) { return nil, goa.MissingPayloadError() } var gerr *goa.ServiceError @@ -3963,7 +3963,7 @@ func DecodeMethodBodyObjectValidateRequest(mux goahttp.Muxer, decoder func(*http ) err = decoder(r).Decode(&body) if err != nil { - if err == io.EOF { + if errors.Is(err, io.EOF) { return nil, goa.MissingPayloadError() } var gerr *goa.ServiceError @@ -3995,7 +3995,7 @@ func DecodeMethodBodyUnionRequest(mux goahttp.Muxer, decoder func(*http.Request) ) err = decoder(r).Decode(&body) if err != nil { - if err == io.EOF { + if errors.Is(err, io.EOF) { return nil, goa.MissingPayloadError() } var gerr *goa.ServiceError @@ -4025,7 +4025,7 @@ func DecodeMethodBodyUnionValidateRequest(mux goahttp.Muxer, decoder func(*http. ) err = decoder(r).Decode(&body) if err != nil { - if err == io.EOF { + if errors.Is(err, io.EOF) { return nil, goa.MissingPayloadError() } var gerr *goa.ServiceError @@ -4055,7 +4055,7 @@ func DecodeMethodBodyUnionUserRequest(mux goahttp.Muxer, decoder func(*http.Requ ) err = decoder(r).Decode(&body) if err != nil { - if err == io.EOF { + if errors.Is(err, io.EOF) { return nil, goa.MissingPayloadError() } var gerr *goa.ServiceError @@ -4085,7 +4085,7 @@ func DecodeMethodBodyUnionUserValidateRequest(mux goahttp.Muxer, decoder func(*h ) err = decoder(r).Decode(&body) if err != nil { - if err == io.EOF { + if errors.Is(err, io.EOF) { return nil, goa.MissingPayloadError() } var gerr *goa.ServiceError @@ -4115,7 +4115,7 @@ func DecodeMethodBodyArrayStringRequest(mux goahttp.Muxer, decoder func(*http.Re ) err = decoder(r).Decode(&body) if err != nil { - if err == io.EOF { + if errors.Is(err, io.EOF) { return nil, goa.MissingPayloadError() } var gerr *goa.ServiceError @@ -4142,7 +4142,7 @@ func DecodeMethodBodyArrayStringValidateRequest(mux goahttp.Muxer, decoder func( ) err = decoder(r).Decode(&body) if err != nil { - if err == io.EOF { + if errors.Is(err, io.EOF) { return nil, goa.MissingPayloadError() } var gerr *goa.ServiceError @@ -4172,7 +4172,7 @@ func DecodeMethodBodyArrayUserRequest(mux goahttp.Muxer, decoder func(*http.Requ ) err = decoder(r).Decode(&body) if err != nil { - if err == io.EOF { + if errors.Is(err, io.EOF) { return nil, goa.MissingPayloadError() } var gerr *goa.ServiceError @@ -4202,7 +4202,7 @@ func DecodeMethodBodyArrayUserValidateRequest(mux goahttp.Muxer, decoder func(*h ) err = decoder(r).Decode(&body) if err != nil { - if err == io.EOF { + if errors.Is(err, io.EOF) { return nil, goa.MissingPayloadError() } var gerr *goa.ServiceError @@ -4232,7 +4232,7 @@ func DecodeMethodBodyMapStringRequest(mux goahttp.Muxer, decoder func(*http.Requ ) err = decoder(r).Decode(&body) if err != nil { - if err == io.EOF { + if errors.Is(err, io.EOF) { return nil, goa.MissingPayloadError() } var gerr *goa.ServiceError @@ -4258,7 +4258,7 @@ func DecodeMethodBodyMapStringValidateRequest(mux goahttp.Muxer, decoder func(*h ) err = decoder(r).Decode(&body) if err != nil { - if err == io.EOF { + if errors.Is(err, io.EOF) { return nil, goa.MissingPayloadError() } var gerr *goa.ServiceError @@ -4288,7 +4288,7 @@ func DecodeMethodBodyMapUserRequest(mux goahttp.Muxer, decoder func(*http.Reques ) err = decoder(r).Decode(&body) if err != nil { - if err == io.EOF { + if errors.Is(err, io.EOF) { return nil, goa.MissingPayloadError() } var gerr *goa.ServiceError @@ -4318,7 +4318,7 @@ func DecodeMethodBodyMapUserValidateRequest(mux goahttp.Muxer, decoder func(*htt ) err = decoder(r).Decode(&body) if err != nil { - if err == io.EOF { + if errors.Is(err, io.EOF) { return nil, goa.MissingPayloadError() } var gerr *goa.ServiceError @@ -4365,7 +4365,7 @@ func DecodeMethodBodyPrimitiveStringValidateRequest(mux goahttp.Muxer, decoder f ) err = decoder(r).Decode(&body) if err != nil { - if err == io.EOF { + if errors.Is(err, io.EOF) { return nil, goa.MissingPayloadError() } var gerr *goa.ServiceError @@ -4398,7 +4398,7 @@ func DecodeMethodBodyPrimitiveBoolValidateRequest(mux goahttp.Muxer, decoder fun ) err = decoder(r).Decode(&body) if err != nil { - if err == io.EOF { + if errors.Is(err, io.EOF) { return nil, goa.MissingPayloadError() } var gerr *goa.ServiceError @@ -4431,7 +4431,7 @@ func DecodeMethodBodyPrimitiveArrayStringValidateRequest(mux goahttp.Muxer, deco ) err = decoder(r).Decode(&body) if err != nil { - if err == io.EOF { + if errors.Is(err, io.EOF) { return nil, goa.MissingPayloadError() } var gerr *goa.ServiceError @@ -4469,7 +4469,7 @@ func DecodeMethodBodyPrimitiveArrayBoolValidateRequest(mux goahttp.Muxer, decode ) err = decoder(r).Decode(&body) if err != nil { - if err == io.EOF { + if errors.Is(err, io.EOF) { return nil, goa.MissingPayloadError() } var gerr *goa.ServiceError @@ -4507,7 +4507,7 @@ func DecodeMethodBodyPrimitiveArrayUserRequiredRequest(mux goahttp.Muxer, decode ) err = decoder(r).Decode(&body) if err != nil { - if err == io.EOF { + if errors.Is(err, io.EOF) { return nil, goa.MissingPayloadError() } var gerr *goa.ServiceError @@ -4544,7 +4544,7 @@ func DecodeMethodBodyPrimitiveArrayUserValidateRequest(mux goahttp.Muxer, decode ) err = decoder(r).Decode(&body) if err != nil { - if err == io.EOF { + if errors.Is(err, io.EOF) { return nil, goa.MissingPayloadError() } var gerr *goa.ServiceError @@ -4584,7 +4584,7 @@ func DecodeMethodBodyPrimitiveArrayUserRequest(mux goahttp.Muxer, decoder func(* ) err = decoder(r).Decode(&body) if err != nil { - if err == io.EOF { + if errors.Is(err, io.EOF) { err = nil } else { var gerr *goa.ServiceError @@ -4612,7 +4612,7 @@ func DecodeMethodBodyPrimitiveArrayUserRequest(mux goahttp.Muxer, decoder func(* ) err = decoder(r).Decode(&body) if err != nil { - if err == io.EOF { + if errors.Is(err, io.EOF) { err = nil } else { var gerr *goa.ServiceError @@ -4640,7 +4640,7 @@ func DecodeMethodBodyPrimitiveArrayUserValidateRequest(mux goahttp.Muxer, decode ) err = decoder(r).Decode(&body) if err != nil { - if err == io.EOF { + if errors.Is(err, io.EOF) { return nil, goa.MissingPayloadError() } var gerr *goa.ServiceError @@ -4675,7 +4675,7 @@ func DecodeMethodBodyQueryObjectRequest(mux goahttp.Muxer, decoder func(*http.Re ) err = decoder(r).Decode(&body) if err != nil { - if err == io.EOF { + if errors.Is(err, io.EOF) { return nil, goa.MissingPayloadError() } var gerr *goa.ServiceError @@ -4710,7 +4710,7 @@ func DecodeMethodBodyQueryObjectValidateRequest(mux goahttp.Muxer, decoder func( ) err = decoder(r).Decode(&body) if err != nil { - if err == io.EOF { + if errors.Is(err, io.EOF) { return nil, goa.MissingPayloadError() } var gerr *goa.ServiceError @@ -4752,7 +4752,7 @@ func DecodeMethodBodyQueryUserRequest(mux goahttp.Muxer, decoder func(*http.Requ ) err = decoder(r).Decode(&body) if err != nil { - if err == io.EOF { + if errors.Is(err, io.EOF) { return nil, goa.MissingPayloadError() } var gerr *goa.ServiceError @@ -4786,7 +4786,7 @@ func DecodeMethodBodyQueryUserValidateRequest(mux goahttp.Muxer, decoder func(*h ) err = decoder(r).Decode(&body) if err != nil { - if err == io.EOF { + if errors.Is(err, io.EOF) { return nil, goa.MissingPayloadError() } var gerr *goa.ServiceError @@ -4828,7 +4828,7 @@ func DecodeMethodBodyPathObjectRequest(mux goahttp.Muxer, decoder func(*http.Req ) err = decoder(r).Decode(&body) if err != nil { - if err == io.EOF { + if errors.Is(err, io.EOF) { return nil, goa.MissingPayloadError() } var gerr *goa.ServiceError @@ -4862,7 +4862,7 @@ func DecodeMethodBodyPathObjectValidateRequest(mux goahttp.Muxer, decoder func(* ) err = decoder(r).Decode(&body) if err != nil { - if err == io.EOF { + if errors.Is(err, io.EOF) { return nil, goa.MissingPayloadError() } var gerr *goa.ServiceError @@ -4903,7 +4903,7 @@ func DecodeMethodBodyPathUserRequest(mux goahttp.Muxer, decoder func(*http.Reque ) err = decoder(r).Decode(&body) if err != nil { - if err == io.EOF { + if errors.Is(err, io.EOF) { return nil, goa.MissingPayloadError() } var gerr *goa.ServiceError @@ -4936,7 +4936,7 @@ func DecodeMethodUserBodyPathValidateRequest(mux goahttp.Muxer, decoder func(*ht ) err = decoder(r).Decode(&body) if err != nil { - if err == io.EOF { + if errors.Is(err, io.EOF) { return nil, goa.MissingPayloadError() } var gerr *goa.ServiceError @@ -4977,7 +4977,7 @@ func DecodeMethodBodyQueryPathObjectRequest(mux goahttp.Muxer, decoder func(*htt ) err = decoder(r).Decode(&body) if err != nil { - if err == io.EOF { + if errors.Is(err, io.EOF) { return nil, goa.MissingPayloadError() } var gerr *goa.ServiceError @@ -5016,7 +5016,7 @@ func DecodeMethodBodyQueryPathObjectValidateRequest(mux goahttp.Muxer, decoder f ) err = decoder(r).Decode(&body) if err != nil { - if err == io.EOF { + if errors.Is(err, io.EOF) { return nil, goa.MissingPayloadError() } var gerr *goa.ServiceError @@ -5063,7 +5063,7 @@ func DecodeMethodBodyQueryPathUserRequest(mux goahttp.Muxer, decoder func(*http. ) err = decoder(r).Decode(&body) if err != nil { - if err == io.EOF { + if errors.Is(err, io.EOF) { return nil, goa.MissingPayloadError() } var gerr *goa.ServiceError @@ -5102,7 +5102,7 @@ func DecodeMethodBodyQueryPathUserValidateRequest(mux goahttp.Muxer, decoder fun ) err = decoder(r).Decode(&body) if err != nil { - if err == io.EOF { + if errors.Is(err, io.EOF) { return nil, goa.MissingPayloadError() } var gerr *goa.ServiceError @@ -5244,7 +5244,7 @@ func DecodeMethodMapQueryObjectRequest(mux goahttp.Muxer, decoder func(*http.Req ) err = decoder(r).Decode(&body) if err != nil { - if err == io.EOF { + if errors.Is(err, io.EOF) { return nil, goa.MissingPayloadError() } var gerr *goa.ServiceError @@ -5376,7 +5376,7 @@ func DecodeMethodARequest(mux goahttp.Muxer, decoder func(*http.Request) goahttp ) err = decoder(r).Decode(&body) if err != nil { - if err == io.EOF { + if errors.Is(err, io.EOF) { return nil, goa.MissingPayloadError() } var gerr *goa.ServiceError @@ -6123,7 +6123,7 @@ func DecodeMethodBodyCustomNameRequest(mux goahttp.Muxer, decoder func(*http.Req ) err = decoder(r).Decode(&body) if err != nil { - if err == io.EOF { + if errors.Is(err, io.EOF) { return nil, goa.MissingPayloadError() } var gerr *goa.ServiceError