From 9ed332a5b0d6e0e349a3afa08e52c5a47579c6c8 Mon Sep 17 00:00:00 2001 From: Matthieu MOREL Date: Mon, 28 Oct 2024 14:12:23 +0100 Subject: [PATCH] chore: enable usestdlibvars linter (#2850) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Matthieu MOREL Co-authored-by: Manuel de la Peña Co-authored-by: Steven Hartland --- .golangci.yml | 1 + modules/elasticsearch/elasticsearch_test.go | 4 ++-- modules/ollama/examples_test.go | 2 +- modules/opensearch/opensearch_test.go | 2 +- 4 files changed, 5 insertions(+), 4 deletions(-) diff --git a/.golangci.yml b/.golangci.yml index 7c421f0be6..b8391990ac 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -10,6 +10,7 @@ linters: - nakedret - testifylint - thelper + - usestdlibvars linters-settings: nakedret: diff --git a/modules/elasticsearch/elasticsearch_test.go b/modules/elasticsearch/elasticsearch_test.go index fdfe636769..99829e94d3 100644 --- a/modules/elasticsearch/elasticsearch_test.go +++ b/modules/elasticsearch/elasticsearch_test.go @@ -87,7 +87,7 @@ func TestElasticsearch(t *testing.T) { httpClient := configureHTTPClient(esContainer) - req, err := http.NewRequest("GET", esContainer.Settings.Address, nil) + req, err := http.NewRequest(http.MethodGet, esContainer.Settings.Address, nil) require.NoError(t, err) // set the password for the request using the Authentication header @@ -201,7 +201,7 @@ func TestElasticsearch8WithoutCredentials(t *testing.T) { httpClient := configureHTTPClient(ctr) - req, err := http.NewRequest("GET", ctr.Settings.Address, nil) + req, err := http.NewRequest(http.MethodGet, ctr.Settings.Address, nil) require.NoError(t, err) // elastic:changeme are the default credentials for Elasticsearch 8 diff --git a/modules/ollama/examples_test.go b/modules/ollama/examples_test.go index 46d65ebe0a..e9ac3ce0fa 100644 --- a/modules/ollama/examples_test.go +++ b/modules/ollama/examples_test.go @@ -85,7 +85,7 @@ func ExampleRun_withModel_llama2_http() { "prompt":"Why is the sky blue?" }` - req, err := http.NewRequest("POST", fmt.Sprintf("%s/api/generate", connectionStr), strings.NewReader(payload)) + req, err := http.NewRequest(http.MethodPost, fmt.Sprintf("%s/api/generate", connectionStr), strings.NewReader(payload)) if err != nil { log.Printf("failed to create request: %s", err) return diff --git a/modules/opensearch/opensearch_test.go b/modules/opensearch/opensearch_test.go index 3829ea2dfb..15304dbfd6 100644 --- a/modules/opensearch/opensearch_test.go +++ b/modules/opensearch/opensearch_test.go @@ -24,7 +24,7 @@ func TestOpenSearch(t *testing.T) { client := &http.Client{} - req, err := http.NewRequest("GET", address, nil) + req, err := http.NewRequest(http.MethodGet, address, nil) require.NoError(t, err) resp, err := client.Do(req)