Skip to content

Commit

Permalink
update golangci-lint action to v3, golangci-lint to v1.48.0 (#3499)
Browse files Browse the repository at this point in the history
* run gofmt -s -w

* stop using the deprecated io/ioutil package

* update golangci-lint action to v3, golangci-lint to v1.48.0
  • Loading branch information
marten-seemann committed Aug 10, 2022
1 parent 7ebe143 commit 498475f
Show file tree
Hide file tree
Showing 20 changed files with 38 additions and 36 deletions.
7 changes: 5 additions & 2 deletions .github/workflows/lint.yml
Expand Up @@ -25,7 +25,10 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-go@v2
with:
go-version: "1.19.x"
- name: golangci-lint
uses: golangci/golangci-lint-action@v2
uses: golangci/golangci-lint-action@v3
with:
version: v1.45.2
version: v1.48.0
3 changes: 1 addition & 2 deletions example/main.go
Expand Up @@ -7,7 +7,6 @@ import (
"flag"
"fmt"
"io"
"io/ioutil"
"log"
"mime/multipart"
"net/http"
Expand Down Expand Up @@ -93,7 +92,7 @@ func setupHandler(www string) http.Handler {
})

mux.HandleFunc("/demo/echo", func(w http.ResponseWriter, r *http.Request) {
body, err := ioutil.ReadAll(r.Body)
body, err := io.ReadAll(r.Body)
if err != nil {
fmt.Printf("error reading body while handling /echo: %s\n", err.Error())
}
Expand Down
1 change: 1 addition & 0 deletions fuzzing/frames/fuzz.go
Expand Up @@ -25,6 +25,7 @@ func toEncLevel(v uint8) protocol.EncryptionLevel {
}

// Fuzz fuzzes the QUIC frames.
//
//go:generate go run ./cmd/corpus.go
func Fuzz(data []byte) int {
if len(data) < PrefixLen {
Expand Down
7 changes: 4 additions & 3 deletions fuzzing/handshake/fuzz.go
Expand Up @@ -7,7 +7,7 @@ import (
"crypto/x509"
"errors"
"fmt"
"io/ioutil"
"io"
"log"
"math"
mrand "math/rand"
Expand Down Expand Up @@ -249,6 +249,7 @@ const (
)

// Fuzz fuzzes the TLS 1.3 handshake used by QUIC.
//
//go:generate go run ./cmd/corpus.go
func Fuzz(data []byte) int {
if len(data) < PrefixLen {
Expand Down Expand Up @@ -353,10 +354,10 @@ func runHandshake(runConfig [confLen]byte, messageConfig uint8, clientConf *tls.
serverConf.NextProtos = []string{alpnWrong, alpn}
}
if helper.NthBit(runConfig[3], 6) {
serverConf.KeyLogWriter = ioutil.Discard
serverConf.KeyLogWriter = io.Discard
}
if helper.NthBit(runConfig[3], 7) {
clientConf.KeyLogWriter = ioutil.Discard
clientConf.KeyLogWriter = io.Discard
}
clientTP := getTransportParameters(runConfig[4] & 0x3)
if helper.NthBit(runConfig[4], 3) {
Expand Down
1 change: 1 addition & 0 deletions fuzzing/header/fuzz.go
Expand Up @@ -14,6 +14,7 @@ const version = protocol.VersionTLS
const PrefixLen = 1

// Fuzz fuzzes the QUIC header.
//
//go:generate go run ./cmd/corpus.go
func Fuzz(data []byte) int {
if len(data) < PrefixLen {
Expand Down
3 changes: 1 addition & 2 deletions fuzzing/internal/helper/helper.go
Expand Up @@ -8,7 +8,6 @@ import (
"crypto/x509"
"crypto/x509/pkix"
"encoding/hex"
"io/ioutil"
"math/big"
"os"
"path/filepath"
Expand All @@ -33,7 +32,7 @@ func WriteCorpusFile(path string, data []byte) error {
}
}
hash := sha1.Sum(data)
return ioutil.WriteFile(filepath.Join(path, hex.EncodeToString(hash[:])), data, 0o644)
return os.WriteFile(filepath.Join(path, hex.EncodeToString(hash[:])), data, 0o644)
}

// WriteCorpusFileWithPrefix writes data to a corpus file in directory path.
Expand Down
7 changes: 3 additions & 4 deletions fuzzing/internal/helper/helper_test.go
Expand Up @@ -2,7 +2,6 @@ package helper

import (
"fmt"
"io/ioutil"
"os"
"path/filepath"

Expand All @@ -15,7 +14,7 @@ var _ = Describe("exporting", func() {

BeforeEach(func() {
var err error
dir, err = ioutil.TempDir("", "fuzzing-helper")
dir, err = os.MkdirTemp("", "fuzzing-helper")
Expect(err).ToNot(HaveOccurred())
fmt.Fprintf(GinkgoWriter, "Created temporary directory %s", dir)
})
Expand All @@ -32,7 +31,7 @@ var _ = Describe("exporting", func() {
Expect(WriteCorpusFile(dir, []byte("lorem ipsum"))).To(Succeed())
path := filepath.Join(dir, expectedShaSum)
Expect(path).To(BeARegularFile())
b, err := ioutil.ReadFile(path)
b, err := os.ReadFile(path)
Expect(err).ToNot(HaveOccurred())
Expect(string(b)).To(Equal(data))
})
Expand All @@ -45,7 +44,7 @@ var _ = Describe("exporting", func() {
Expect(WriteCorpusFileWithPrefix(dir, []byte("lorem ipsum"), prefixLen)).To(Succeed())
path := filepath.Join(dir, expectedShaSum)
Expect(path).To(BeARegularFile())
b, err := ioutil.ReadFile(path)
b, err := os.ReadFile(path)
Expect(err).ToNot(HaveOccurred())
Expect(b[:prefixLen]).To(Equal(make([]byte, prefixLen)))
Expect(string(b[prefixLen:])).To(Equal(data))
Expand Down
1 change: 1 addition & 0 deletions fuzzing/transportparameters/fuzz.go
Expand Up @@ -13,6 +13,7 @@ import (
const PrefixLen = 1

// Fuzz fuzzes the QUIC transport parameters.
//
//go:generate go run ./cmd/corpus.go
func Fuzz(data []byte) int {
if len(data) <= PrefixLen {
Expand Down
5 changes: 2 additions & 3 deletions http3/client_test.go
Expand Up @@ -8,7 +8,6 @@ import (
"errors"
"fmt"
"io"
"io/ioutil"
"net/http"
"time"

Expand Down Expand Up @@ -990,7 +989,7 @@ var _ = Describe("Client", func() {

rsp, err := client.RoundTripOpt(req, RoundTripOpt{})
Expect(err).ToNot(HaveOccurred())
data, err := ioutil.ReadAll(rsp.Body)
data, err := io.ReadAll(rsp.Body)
Expect(err).ToNot(HaveOccurred())
Expect(rsp.ContentLength).To(BeEquivalentTo(-1))
Expect(string(data)).To(Equal("gzipped response"))
Expand All @@ -1013,7 +1012,7 @@ var _ = Describe("Client", func() {

rsp, err := client.RoundTripOpt(req, RoundTripOpt{})
Expect(err).ToNot(HaveOccurred())
data, err := ioutil.ReadAll(rsp.Body)
data, err := io.ReadAll(rsp.Body)
Expect(err).ToNot(HaveOccurred())
Expect(string(data)).To(Equal("not gzipped"))
Expect(rsp.Header.Get("Content-Encoding")).To(BeEmpty())
Expand Down
3 changes: 1 addition & 2 deletions http3/frames.go
Expand Up @@ -5,7 +5,6 @@ import (
"errors"
"fmt"
"io"
"io/ioutil"

"github.com/lucas-clemente/quic-go/internal/protocol"
"github.com/lucas-clemente/quic-go/quicvarint"
Expand Down Expand Up @@ -65,7 +64,7 @@ func parseNextFrame(r io.Reader, unknownFrameHandler unknownFrameHandlerFunc) (f
case 0xd: // MAX_PUSH_ID
}
// skip over unknown frames
if _, err := io.CopyN(ioutil.Discard, qr, int64(l)); err != nil {
if _, err := io.CopyN(io.Discard, qr, int64(l)); err != nil {
return nil, err
}
}
Expand Down
4 changes: 2 additions & 2 deletions http3/request_writer.go
Expand Up @@ -233,8 +233,8 @@ func authorityAddr(scheme string, authority string) (addr string) {
// validPseudoPath reports whether v is a valid :path pseudo-header
// value. It must be either:
//
// *) a non-empty string starting with '/'
// *) the string '*', for OPTIONS requests.
// *) a non-empty string starting with '/'
// *) the string '*', for OPTIONS requests.
//
// For now this is only used a quick check for deciding when to clean
// up Opaque URLs before sending requests from the Transport.
Expand Down
3 changes: 2 additions & 1 deletion http3/server.go
Expand Up @@ -637,7 +637,8 @@ var ErrNoAltSvcPort = errors.New("no port can be announced, specify it explicitl
// If no listener's Addr().String() returns an address with a valid port, Server.Addr will be used
// to extract the port, if specified.
// For example, a server launched using ListenAndServe on an address with port 443 would set:
// Alt-Svc: h3=":443"; ma=2592000,h3-29=":443"; ma=2592000
//
// Alt-Svc: h3=":443"; ma=2592000,h3-29=":443"; ma=2592000
func (s *Server) SetQuicHeaders(hdr http.Header) error {
s.mutex.RLock()
defer s.mutex.RUnlock()
Expand Down
3 changes: 1 addition & 2 deletions integrationtests/self/tracer_test.go
Expand Up @@ -6,7 +6,6 @@ import (
"context"
"fmt"
"io"
"io/ioutil"
mrand "math/rand"
"net"
"time"
Expand Down Expand Up @@ -90,7 +89,7 @@ var _ = Describe("Handshake tests", func() {
return nil
}
fmt.Fprintf(GinkgoWriter, "%s qlog tracing connection %x\n", p, connectionID)
return utils.NewBufferedWriteCloser(bufio.NewWriter(&bytes.Buffer{}), ioutil.NopCloser(nil))
return utils.NewBufferedWriteCloser(bufio.NewWriter(&bytes.Buffer{}), io.NopCloser(nil))
}))
}
if enableCustomTracer {
Expand Down
1 change: 1 addition & 0 deletions internal/flowcontrol/base_flow_controller_test.go
Expand Up @@ -13,6 +13,7 @@ import (
)

// on the CIs, the timing is a lot less precise, so scale every duration by this factor
//
//nolint:unparam
func scaleDuration(t time.Duration) time.Duration {
scaleFactor := 1
Expand Down
4 changes: 2 additions & 2 deletions internal/testdata/cert.go
Expand Up @@ -3,7 +3,7 @@ package testdata
import (
"crypto/tls"
"crypto/x509"
"io/ioutil"
"os"
"path"
"runtime"
)
Expand Down Expand Up @@ -38,7 +38,7 @@ func GetTLSConfig() *tls.Config {
// AddRootCA adds the root CA certificate to a cert pool
func AddRootCA(certPool *x509.CertPool) {
caCertPath := path.Join(certPath, "ca.pem")
caCertRaw, err := ioutil.ReadFile(caCertPath)
caCertRaw, err := os.ReadFile(caCertPath)
if err != nil {
panic(err)
}
Expand Down
4 changes: 2 additions & 2 deletions internal/testdata/cert_test.go
Expand Up @@ -2,7 +2,7 @@ package testdata

import (
"crypto/tls"
"io/ioutil"
"io"

. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
Expand All @@ -24,7 +24,7 @@ var _ = Describe("certificates", func() {

conn, err := tls.Dial("tcp", "localhost:4433", &tls.Config{RootCAs: GetRootCA()})
Expect(err).ToNot(HaveOccurred())
data, err := ioutil.ReadAll(conn)
data, err := io.ReadAll(conn)
Expect(err).ToNot(HaveOccurred())
Expect(string(data)).To(Equal("foobar"))
})
Expand Down
4 changes: 2 additions & 2 deletions interop/http09/client.go
Expand Up @@ -4,7 +4,7 @@ import (
"context"
"crypto/tls"
"errors"
"io/ioutil"
"io"
"log"
"net"
"net/http"
Expand Down Expand Up @@ -118,7 +118,7 @@ func (c *client) doRequest(req *http.Request) (*http.Response, error) {
ProtoMajor: 0,
ProtoMinor: 9,
Request: req,
Body: ioutil.NopCloser(str),
Body: io.NopCloser(str),
}
return rsp, nil
}
Expand Down
6 changes: 3 additions & 3 deletions interop/http09/http_test.go
Expand Up @@ -3,7 +3,7 @@ package http09
import (
"crypto/tls"
"fmt"
"io/ioutil"
"io"
"net"
"net/http"
"net/http/httptest"
Expand Down Expand Up @@ -62,7 +62,7 @@ var _ = Describe("HTTP 0.9 integration tests", func() {
)
rsp, err := rt.RoundTrip(req)
Expect(err).ToNot(HaveOccurred())
data, err := ioutil.ReadAll(rsp.Body)
data, err := io.ReadAll(rsp.Body)
Expect(err).ToNot(HaveOccurred())
Expect(data).To(Equal([]byte("Hello World!")))
})
Expand All @@ -83,7 +83,7 @@ var _ = Describe("HTTP 0.9 integration tests", func() {
)
rsp, err := rt.RoundTrip(req)
Expect(err).ToNot(HaveOccurred())
data, err := ioutil.ReadAll(rsp.Body)
data, err := io.ReadAll(rsp.Body)
Expect(err).ToNot(HaveOccurred())
Expect(data).To(Equal([]byte("done")))
})
Expand Down
3 changes: 1 addition & 2 deletions interop/http09/server.go
Expand Up @@ -4,7 +4,6 @@ import (
"context"
"errors"
"io"
"io/ioutil"
"log"
"net"
"net/http"
Expand Down Expand Up @@ -102,7 +101,7 @@ func (s *Server) handleConn(conn quic.Connection) {
}

func (s *Server) handleStream(str quic.Stream) error {
reqBytes, err := ioutil.ReadAll(str)
reqBytes, err := io.ReadAll(str)
if err != nil {
return err
}
Expand Down
4 changes: 2 additions & 2 deletions quic_suite_test.go
@@ -1,7 +1,7 @@
package quic

import (
"io/ioutil"
"io"
"log"
"sync"
"testing"
Expand All @@ -26,7 +26,7 @@ var _ = BeforeEach(func() {
})

var _ = BeforeSuite(func() {
log.SetOutput(ioutil.Discard)
log.SetOutput(io.Discard)
})

var _ = AfterEach(func() {
Expand Down

0 comments on commit 498475f

Please sign in to comment.