diff --git a/.github/workflows/gopenqa.yml b/.github/workflows/gopenqa.yml index 12f3579..58f1a6b 100644 --- a/.github/workflows/gopenqa.yml +++ b/.github/workflows/gopenqa.yml @@ -12,7 +12,7 @@ jobs: - name: Setup go uses: actions/setup-go@v5 with: - go-version: '1.14' + go-version: '1.16' - name: Install requirements run: go get github.com/streadway/amqp - name: Run test suite diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index c974c0e..bd90080 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -1,4 +1,4 @@ -image: golang:1.14 +image: golang:1.16 test: script: diff --git a/cmd/gopenqa/gopenqa.go b/cmd/gopenqa/gopenqa.go index 0c07246..d3b9e60 100644 --- a/cmd/gopenqa/gopenqa.go +++ b/cmd/gopenqa/gopenqa.go @@ -7,7 +7,7 @@ import ( "bufio" "encoding/json" "fmt" - "io/ioutil" + "io" "os" "strconv" "strings" @@ -150,18 +150,18 @@ func readMachines(filename string) ([]gopenqa.Machine, error) { var err error if filename == "" { - data, err = ioutil.ReadAll(os.Stdin) + data, err = io.ReadAll(os.Stdin) if err != nil { machines := make([]gopenqa.Machine, 0) return machines, err } } else { - // TODO: Don't use ioutil.ReadAll + // TODO: Don't use io.ReadAll if file, err := os.Open(filename); err != nil { return make([]gopenqa.Machine, 0), err } else { defer file.Close() - data, err = ioutil.ReadAll(file) + data, err = io.ReadAll(file) if err != nil { return make([]gopenqa.Machine, 0), err } @@ -192,17 +192,17 @@ func readProducts(filename string) ([]gopenqa.Product, error) { var err error if filename == "" { - data, err = ioutil.ReadAll(os.Stdin) + data, err = io.ReadAll(os.Stdin) if err != nil { return make([]gopenqa.Product, 0), err } } else { - // TODO: Don't use ioutil.ReadAll + // TODO: Don't use io.ReadAll if file, err := os.Open(filename); err != nil { return make([]gopenqa.Product, 0), err } else { defer file.Close() - data, err = ioutil.ReadAll(file) + data, err = io.ReadAll(file) if err != nil { return make([]gopenqa.Product, 0), err } @@ -233,17 +233,17 @@ func readJobGroups(filename string) ([]gopenqa.JobGroup, error) { var err error if filename == "" { - data, err = ioutil.ReadAll(os.Stdin) + data, err = io.ReadAll(os.Stdin) if err != nil { return make([]gopenqa.JobGroup, 0), err } } else { - // TODO: Don't use ioutil.ReadAll + // TODO: Don't use io.ReadAll if file, err := os.Open(filename); err != nil { return make([]gopenqa.JobGroup, 0), err } else { defer file.Close() - data, err = ioutil.ReadAll(file) + data, err = io.ReadAll(file) if err != nil { return make([]gopenqa.JobGroup, 0), err } diff --git a/go.mod b/go.mod index 1b84d6f..f662cf2 100644 --- a/go.mod +++ b/go.mod @@ -1,6 +1,6 @@ module github.com/grisu48/gopenqa -go 1.14 +go 1.16 require ( github.com/google/go-cmp v0.6.0 // indirect diff --git a/gopenqa.go b/gopenqa.go index 3cae932..df92afd 100644 --- a/gopenqa.go +++ b/gopenqa.go @@ -6,7 +6,7 @@ import ( "crypto/sha1" "encoding/json" "fmt" - "io/ioutil" + "io" "net/http" "net/url" "os" @@ -294,9 +294,9 @@ func (i *Instance) request(method string, url string, data []byte) ([]byte, erro return make([]byte, 0), err } - // First read body + // First read body to have it ready in case of errors defer r.Body.Close() - buf, err := ioutil.ReadAll(r.Body) // TODO: Limit read size + buf, err := io.ReadAll(r.Body) // TODO: Limit read size if err != nil { return buf, err }