From 4acb644b791b0cb98de596ca42b7b58c8656e684 Mon Sep 17 00:00:00 2001 From: web3-bot Date: Thu, 25 Aug 2022 12:20:48 +0000 Subject: [PATCH 1/4] bump go.mod to Go 1.18 and run go fix --- fuzz.go | 1 - go.mod | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/fuzz.go b/fuzz.go index 3cf23ff..317f555 100644 --- a/fuzz.go +++ b/fuzz.go @@ -1,5 +1,4 @@ //go:build gofuzz -// +build gofuzz package msgio diff --git a/go.mod b/go.mod index 5a45923..8709cb9 100644 --- a/go.mod +++ b/go.mod @@ -1,6 +1,6 @@ module github.com/libp2p/go-msgio -go 1.17 +go 1.18 require ( github.com/gogo/protobuf v1.3.2 From 2d273dae111ad0128563edab3fa29c3537e7aacd Mon Sep 17 00:00:00 2001 From: web3-bot Date: Thu, 25 Aug 2022 12:20:53 +0000 Subject: [PATCH 2/4] stop using the deprecated io/ioutil package --- msgio.go | 2 +- msgio/msgio.go | 3 +-- num.go | 5 +++-- protoio/interfaces.go | 10 +++++----- protoio/uvarint_reader.go | 10 +++++----- protoio/uvarint_test.go | 10 +++++----- protoio/uvarint_writer.go | 10 +++++----- 7 files changed, 25 insertions(+), 25 deletions(-) diff --git a/msgio.go b/msgio.go index 5e61142..7543ea0 100644 --- a/msgio.go +++ b/msgio.go @@ -8,7 +8,7 @@ import ( pool "github.com/libp2p/go-buffer-pool" ) -// ErrMsgTooLarge is returned when the message length is exessive +// ErrMsgTooLarge is returned when the message length is exessive var ErrMsgTooLarge = errors.New("message too large") const ( diff --git a/msgio/msgio.go b/msgio/msgio.go index a4293d3..294f4fd 100644 --- a/msgio/msgio.go +++ b/msgio/msgio.go @@ -4,7 +4,6 @@ import ( "flag" "fmt" "io" - "io/ioutil" "os" "strconv" "strings" @@ -94,7 +93,7 @@ func header(w io.Writer, size int) error { } func wrap(w io.Writer, r io.Reader) error { - buf, err := ioutil.ReadAll(r) + buf, err := io.ReadAll(r) if err != nil { return err } diff --git a/num.go b/num.go index 513c199..8ece5ec 100644 --- a/num.go +++ b/num.go @@ -16,8 +16,9 @@ func WriteLen(w io.Writer, l int) error { // ReadLen reads a length from the given reader. // if buf is non-nil, it reuses the buffer. Ex: -// l, err := ReadLen(r, nil) -// _, err := ReadLen(r, buf) +// +// l, err := ReadLen(r, nil) +// _, err := ReadLen(r, buf) func ReadLen(r io.Reader, buf []byte) (int, error) { if len(buf) < 4 { buf = make([]byte, 4) diff --git a/protoio/interfaces.go b/protoio/interfaces.go index 1a42713..e963ad0 100644 --- a/protoio/interfaces.go +++ b/protoio/interfaces.go @@ -1,8 +1,7 @@ -// // Adapted from gogo/protobuf to use multiformats/go-varint for // efficient, interoperable length-prefixing. // -// Protocol Buffers for Go with Gadgets +// # Protocol Buffers for Go with Gadgets // // Copyright (c) 2013, The GoGo Authors. All rights reserved. // http://github.com/gogo/protobuf @@ -11,9 +10,11 @@ // modification, are permitted provided that the following conditions are // met: // -// * Redistributions of source code must retain the above copyright +// - Redistributions of source code must retain the above copyright +// // notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above +// - Redistributions in binary form must reproduce the above +// // copyright notice, this list of conditions and the following disclaimer // in the documentation and/or other materials provided with the // distribution. @@ -29,7 +30,6 @@ // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// package protoio import ( diff --git a/protoio/uvarint_reader.go b/protoio/uvarint_reader.go index 1173467..6722cd3 100644 --- a/protoio/uvarint_reader.go +++ b/protoio/uvarint_reader.go @@ -1,8 +1,7 @@ -// // Adapted from gogo/protobuf to use multiformats/go-varint for // efficient, interoperable length-prefixing. // -// Protocol Buffers for Go with Gadgets +// # Protocol Buffers for Go with Gadgets // // Copyright (c) 2013, The GoGo Authors. All rights reserved. // http://github.com/gogo/protobuf @@ -11,9 +10,11 @@ // modification, are permitted provided that the following conditions are // met: // -// * Redistributions of source code must retain the above copyright +// - Redistributions of source code must retain the above copyright +// // notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above +// - Redistributions in binary form must reproduce the above +// // copyright notice, this list of conditions and the following disclaimer // in the documentation and/or other materials provided with the // distribution. @@ -29,7 +30,6 @@ // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// package protoio import ( diff --git a/protoio/uvarint_test.go b/protoio/uvarint_test.go index 0cde5b2..30dda96 100644 --- a/protoio/uvarint_test.go +++ b/protoio/uvarint_test.go @@ -1,8 +1,7 @@ -// // Adapted from gogo/protobuf to use multiformats/go-varint for // efficient, interoperable length-prefixing. // -// Protocol Buffers for Go with Gadgets +// # Protocol Buffers for Go with Gadgets // // Copyright (c) 2013, The GoGo Authors. All rights reserved. // http://github.com/gogo/protobuf @@ -11,9 +10,11 @@ // modification, are permitted provided that the following conditions are // met: // -// * Redistributions of source code must retain the above copyright +// - Redistributions of source code must retain the above copyright +// // notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above +// - Redistributions in binary form must reproduce the above +// // copyright notice, this list of conditions and the following disclaimer // in the documentation and/or other materials provided with the // distribution. @@ -29,7 +30,6 @@ // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// package protoio_test import ( diff --git a/protoio/uvarint_writer.go b/protoio/uvarint_writer.go index ace982e..e311075 100644 --- a/protoio/uvarint_writer.go +++ b/protoio/uvarint_writer.go @@ -1,8 +1,7 @@ -// // Adapted from gogo/protobuf to use multiformats/go-varint for // efficient, interoperable length-prefixing. // -// Protocol Buffers for Go with Gadgets +// # Protocol Buffers for Go with Gadgets // // Copyright (c) 2013, The GoGo Authors. All rights reserved. // http://github.com/gogo/protobuf @@ -11,9 +10,11 @@ // modification, are permitted provided that the following conditions are // met: // -// * Redistributions of source code must retain the above copyright +// - Redistributions of source code must retain the above copyright +// // notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above +// - Redistributions in binary form must reproduce the above +// // copyright notice, this list of conditions and the following disclaimer // in the documentation and/or other materials provided with the // distribution. @@ -29,7 +30,6 @@ // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// package protoio import ( From a6777e79c525342dbfdeb520e8b4e5a444b2d461 Mon Sep 17 00:00:00 2001 From: web3-bot Date: Thu, 25 Aug 2022 12:20:53 +0000 Subject: [PATCH 3/4] update .github/workflows/go-test.yml --- .github/workflows/go-test.yml | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/.github/workflows/go-test.yml b/.github/workflows/go-test.yml index b86241a..8a1697b 100644 --- a/.github/workflows/go-test.yml +++ b/.github/workflows/go-test.yml @@ -10,16 +10,16 @@ jobs: fail-fast: false matrix: os: [ "ubuntu", "windows", "macos" ] - go: [ "1.17.x", "1.18.x" ] + go: [ "1.18.x", "1.19.x" ] env: COVERAGES: "" runs-on: ${{ format('{0}-latest', matrix.os) }} name: ${{ matrix.os }} (go ${{ matrix.go }}) steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v3 with: submodules: recursive - - uses: actions/setup-go@v2 + - uses: actions/setup-go@v3 with: go-version: ${{ matrix.go }} - name: Go information @@ -43,7 +43,7 @@ jobs: # Use -coverpkg=./..., so that we include cross-package coverage. # If package ./A imports ./B, and ./A's tests also cover ./B, # this means ./B's coverage will be significantly higher than 0%. - run: go test -v -coverprofile=module-coverage.txt -coverpkg=./... ./... + run: go test -v -shuffle=on -coverprofile=module-coverage.txt -coverpkg=./... ./... - name: Run tests (32 bit) if: ${{ matrix.os != 'macos' }} # can't run 32 bit tests on OSX. uses: protocol/multiple-go-modules@v1.2 @@ -52,7 +52,7 @@ jobs: with: run: | export "PATH=${{ env.PATH_386 }}:$PATH" - go test -v ./... + go test -v -shuffle=on ./... - name: Run tests with race detector if: ${{ matrix.os == 'ubuntu' }} # speed things up. Windows and OSX VMs are slow uses: protocol/multiple-go-modules@v1.2 @@ -62,7 +62,7 @@ jobs: shell: bash run: echo "COVERAGES=$(find . -type f -name 'module-coverage.txt' | tr -s '\n' ',' | sed 's/,$//')" >> $GITHUB_ENV - name: Upload coverage to Codecov - uses: codecov/codecov-action@f32b3a3741e1053eb607407145bc9619351dc93b # v2.1.0 + uses: codecov/codecov-action@81cd2dc8148241f03f5839d295e000b8f761e378 # v3.1.0 with: files: '${{ env.COVERAGES }}' env_vars: OS=${{ matrix.os }}, GO=${{ matrix.go }} From 3ba3e1e8f66144d7388547daede5ec13a25d070d Mon Sep 17 00:00:00 2001 From: web3-bot Date: Thu, 25 Aug 2022 12:20:54 +0000 Subject: [PATCH 4/4] update .github/workflows/go-check.yml --- .github/workflows/go-check.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/go-check.yml b/.github/workflows/go-check.yml index 25e1afd..251f7fa 100644 --- a/.github/workflows/go-check.yml +++ b/.github/workflows/go-check.yml @@ -11,12 +11,12 @@ jobs: env: RUNGOGENERATE: false steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v3 with: submodules: recursive - - uses: actions/setup-go@v2 + - uses: actions/setup-go@v3 with: - go-version: "1.18.x" + go-version: "1.19.x" - name: Run repo-specific setup uses: ./.github/actions/go-check-setup if: hashFiles('./.github/actions/go-check-setup') != '' @@ -27,7 +27,7 @@ jobs: echo "RUNGOGENERATE=true" >> $GITHUB_ENV fi - name: Install staticcheck - run: go install honnef.co/go/tools/cmd/staticcheck@d7e217c1ff411395475b2971c0824e1e7cc1af98 # 2022.1 (v0.3.0) + run: go install honnef.co/go/tools/cmd/staticcheck@376210a89477dedbe6fdc4484b233998650d7b3c # 2022.1.3 (v0.3.3) - name: Check that go.mod is tidy uses: protocol/multiple-go-modules@v1.2 with: