From 64e522cb93299cf584df03a2eb3b01627d1a00cc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Palet?= Date: Wed, 27 Sep 2023 09:46:56 +0200 Subject: [PATCH] Replace errors pkg with fmt.Errorf (#27) --- templates/client.mustache | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/templates/client.mustache b/templates/client.mustache index 8023f9c..640cc8d 100644 --- a/templates/client.mustache +++ b/templates/client.mustache @@ -6,7 +6,6 @@ import ( "context" "encoding/json" "encoding/xml" - "errors" "fmt" "io" "log" @@ -314,7 +313,7 @@ func (c *APIClient) prepareRequest( // add form parameters and file if available. if strings.HasPrefix(headerParams["Content-Type"], "multipart/form-data") && len(formParams) > 0 || (len(formFiles) > 0) { if body != nil { - return nil, errors.New("Cannot specify postBody and multipart form at the same time.") + return nil, fmt.Errorf("cannot specify postBody and multipart form at the same time.") } body = &bytes.Buffer{} w := multipart.NewWriter(body) @@ -355,7 +354,7 @@ func (c *APIClient) prepareRequest( if strings.HasPrefix(headerParams["Content-Type"], "application/x-www-form-urlencoded") && len(formParams) > 0 { if body != nil { - return nil, errors.New("Cannot specify postBody and x-www-form-urlencoded form at the same time.") + return nil, fmt.Errorf("cannot specify postBody and x-www-form-urlencoded form at the same time.") } body = &bytes.Buffer{} body.WriteString(formParams.Encode()) @@ -521,14 +520,14 @@ func (c *APIClient) decode(v interface{}, b []byte, contentType string) (err err return err } } else { - return errors.New("Unknown type with GetActualInstance but no unmarshalObj.UnmarshalJSON defined") + return fmt.Errorf("unknown type with GetActualInstance but no unmarshalObj.UnmarshalJSON defined") } } else if err = json.Unmarshal(b, v); err != nil { // simple model return err } return nil } - return errors.New("undefined response type") + return fmt.Errorf("undefined response type") } // Add a file to the multipart request