diff --git a/.github/workflows/lint_and_test.yml b/.github/workflows/lint_and_test.yml index 6b7a3f53f..bbeaaf83e 100644 --- a/.github/workflows/lint_and_test.yml +++ b/.github/workflows/lint_and_test.yml @@ -10,7 +10,7 @@ jobs: name: Lint and Test - ${{ matrix.go-version }} strategy: matrix: - go-version: [1.16.x, 1.17.x, 1.x] + go-version: [1.18.x, 1.19.x, 1.x] platform: [ubuntu-latest] runs-on: ${{ matrix.platform }} steps: diff --git a/commits_test.go b/commits_test.go index 7f022b221..7c08ec823 100644 --- a/commits_test.go +++ b/commits_test.go @@ -19,7 +19,7 @@ package gitlab import ( "encoding/json" "fmt" - "io/ioutil" + "io" "net/http" "reflect" "testing" @@ -108,7 +108,7 @@ func TestSetCommitStatus(t *testing.T) { mux.HandleFunc("/api/v4/projects/1/statuses/b0b3a907f41409829b307a28b82fdbd552ee5a27", func(w http.ResponseWriter, r *http.Request) { testMethod(t, r, http.MethodPost) - body, err := ioutil.ReadAll(r.Body) + body, err := io.ReadAll(r.Body) require.NoError(t, err) var content SetCommitStatusOptions diff --git a/gitlab.go b/gitlab.go index 234f58ac8..08b200699 100644 --- a/gitlab.go +++ b/gitlab.go @@ -23,7 +23,6 @@ import ( "encoding/json" "fmt" "io" - "io/ioutil" "math/rand" "mime/multipart" "net/http" @@ -885,7 +884,7 @@ func CheckResponse(r *http.Response) error { } errorResponse := &ErrorResponse{Response: r} - data, err := ioutil.ReadAll(r.Body) + data, err := io.ReadAll(r.Body) if err == nil && data != nil { errorResponse.Body = data diff --git a/gitlab_test.go b/gitlab_test.go index 666739f8a..860e7fb8e 100644 --- a/gitlab_test.go +++ b/gitlab_test.go @@ -21,7 +21,6 @@ import ( "context" "errors" "io" - "io/ioutil" "log" "net/http" "net/http/httptest" @@ -135,7 +134,7 @@ func TestCheckResponse(t *testing.T) { resp := &http.Response{ Request: req.Request, StatusCode: http.StatusBadRequest, - Body: ioutil.NopCloser(strings.NewReader(` + Body: io.NopCloser(strings.NewReader(` { "message": { "prop1": [ @@ -192,7 +191,7 @@ func TestRequestWithContext(t *testing.T) { } func loadFixture(filePath string) []byte { - content, err := ioutil.ReadFile(filePath) + content, err := os.ReadFile(filePath) if err != nil { log.Fatal(err) } diff --git a/group_import_export_test.go b/group_import_export_test.go index d1c5db035..96454ef7b 100644 --- a/group_import_export_test.go +++ b/group_import_export_test.go @@ -2,7 +2,7 @@ package gitlab import ( "fmt" - "io/ioutil" + "io" "log" "net/http" "os" @@ -42,7 +42,7 @@ func TestGroupExportDownload(t *testing.T) { t.Errorf("GroupImportExport.ExportDownload returned error: %v", err) } - data, err := ioutil.ReadAll(export) + data, err := io.ReadAll(export) if err != nil { t.Errorf("Error reading export: %v", err) } @@ -58,7 +58,7 @@ func TestGroupImport(t *testing.T) { defer teardown(server) content := []byte("temporary file's content") - tmpfile, err := ioutil.TempFile("", "example.*.tar.gz") + tmpfile, err := os.CreateTemp(os.TempDir(), "example.*.tar.gz") if err != nil { tmpfile.Close() log.Fatal(err) diff --git a/jobs_test.go b/jobs_test.go index 0abe9b0a7..9c39080ef 100644 --- a/jobs_test.go +++ b/jobs_test.go @@ -18,7 +18,7 @@ package gitlab import ( "fmt" - "io/ioutil" + "io" "net/http" "reflect" "testing" @@ -202,7 +202,7 @@ func TestDownloadSingleArtifactsFileByTagOrBranch(t *testing.T) { t.Fatalf("Jobs.DownloadSingleArtifactsFileByTagOrBranch returns an error: %v", err) } - content, err := ioutil.ReadAll(reader) + content, err := io.ReadAll(reader) if err != nil { t.Fatalf("Jobs.DownloadSingleArtifactsFileByTagOrBranch error reading: %v", err) } diff --git a/projects_test.go b/projects_test.go index f495b3ffa..c21d32834 100644 --- a/projects_test.go +++ b/projects_test.go @@ -19,7 +19,6 @@ package gitlab import ( "bytes" "fmt" - "io/ioutil" "net/http" "os" "reflect" @@ -452,7 +451,7 @@ func TestUploadFile_Retry(t *testing.T) { mux, server, client := setup(t) defer teardown(server) - tf, _ := ioutil.TempFile(os.TempDir(), "test") + tf, _ := os.CreateTemp(os.TempDir(), "test") defer os.Remove(tf.Name()) isFirstRequest := true diff --git a/releases_test.go b/releases_test.go index 0d0fcd865..c02891ff6 100644 --- a/releases_test.go +++ b/releases_test.go @@ -18,7 +18,7 @@ package gitlab import ( "fmt" - "io/ioutil" + "io" "net/http" "strings" "testing" @@ -71,7 +71,7 @@ func TestReleasesService_CreateRelease(t *testing.T) { mux.HandleFunc("/api/v4/projects/1/releases", func(w http.ResponseWriter, r *http.Request) { testMethod(t, r, http.MethodPost) - b, err := ioutil.ReadAll(r.Body) + b, err := io.ReadAll(r.Body) if err != nil { t.Fatalf("unable to read request body") } @@ -116,7 +116,7 @@ func TestReleasesService_CreateReleaseWithAsset(t *testing.T) { mux.HandleFunc("/api/v4/projects/1/releases", func(w http.ResponseWriter, r *http.Request) { testMethod(t, r, http.MethodPost) - b, err := ioutil.ReadAll(r.Body) + b, err := io.ReadAll(r.Body) if err != nil { t.Fatalf("unable to read request body") } @@ -166,7 +166,7 @@ func TestReleasesService_CreateReleaseWithAssetAndNameMetadata(t *testing.T) { mux.HandleFunc("/api/v4/projects/1/releases", func(w http.ResponseWriter, r *http.Request) { testMethod(t, r, http.MethodPost) - b, err := ioutil.ReadAll(r.Body) + b, err := io.ReadAll(r.Body) if err != nil { t.Fatalf("unable to read request body") } @@ -216,7 +216,7 @@ func TestReleasesService_CreateReleaseWithMilestones(t *testing.T) { mux.HandleFunc("/api/v4/projects/1/releases", func(w http.ResponseWriter, r *http.Request) { testMethod(t, r, http.MethodPost) - b, err := ioutil.ReadAll(r.Body) + b, err := io.ReadAll(r.Body) if err != nil { t.Fatalf("unable to read request body") } @@ -262,7 +262,7 @@ func TestReleasesService_CreateReleaseWithReleasedAt(t *testing.T) { mux.HandleFunc("/api/v4/projects/1/releases", func(w http.ResponseWriter, r *http.Request) { testMethod(t, r, http.MethodPost) - b, err := ioutil.ReadAll(r.Body) + b, err := io.ReadAll(r.Body) if err != nil { t.Fatalf("unable to read request body") } @@ -308,7 +308,7 @@ func TestReleasesService_UpdateRelease(t *testing.T) { mux.HandleFunc("/api/v4/projects/1/releases/v0.1", func(w http.ResponseWriter, r *http.Request) { testMethod(t, r, http.MethodPut) - b, err := ioutil.ReadAll(r.Body) + b, err := io.ReadAll(r.Body) if err != nil { t.Fatalf("unable to read request body") } @@ -344,7 +344,7 @@ func TestReleasesService_UpdateReleaseWithMilestones(t *testing.T) { mux.HandleFunc("/api/v4/projects/1/releases/v0.1", func(w http.ResponseWriter, r *http.Request) { testMethod(t, r, http.MethodPut) - b, err := ioutil.ReadAll(r.Body) + b, err := io.ReadAll(r.Body) if err != nil { t.Fatalf("unable to read request body") } @@ -381,7 +381,7 @@ func TestReleasesService_UpdateReleaseWithReleasedAt(t *testing.T) { mux.HandleFunc("/api/v4/projects/1/releases/v0.1", func(w http.ResponseWriter, r *http.Request) { testMethod(t, r, http.MethodPut) - b, err := ioutil.ReadAll(r.Body) + b, err := io.ReadAll(r.Body) if err != nil { t.Fatalf("unable to read request body") }