diff --git a/.github/workflows/go.yml b/.github/workflows/go.yml index 488f061..675eade 100644 --- a/.github/workflows/go.yml +++ b/.github/workflows/go.yml @@ -7,32 +7,45 @@ on: branches: [ main ] jobs: - test: - name: Test + name: Test with latest golang runs-on: ubuntu-latest steps: + - name: Check out repo + uses: actions/checkout@v3 - - name: Set up Go 1.x - uses: actions/setup-go@v2 + - name: Set up latest golang + uses: actions/setup-go@v3 + with: + go-version: ^1.18 + + - name: Test + run: go test -v -race ./... + + test-old: + name: Test with 1.15 + runs-on: ubuntu-latest + steps: + - name: Check out repo + uses: actions/checkout@v3 + + - name: Set up Go 1.15 + uses: actions/setup-go@v3 with: - go-version: ^1.16 - id: go - - - name: Check out code into the Go module directory - uses: actions/checkout@v2 - - - name: Get dependencies - run: | - go get -v -t -d ./... - if [ -f Gopkg.toml ]; then - curl https://raw.githubusercontent.com/golang/dep/master/install.sh | sh - dep ensure - fi - go install github.com/golangci/golangci-lint/cmd/golangci-lint@latest + go-version: 1.15 - name: Test run: go test -v -race ./... - - name: Lint - run: golangci-lint run ./... + lint: + name: Lint + runs-on: ubuntu-latest + steps: + - uses: actions/setup-go@v3 + with: + go-version: 1.17 + - uses: actions/checkout@v3 + - name: golangci-lint + uses: golangci/golangci-lint-action@v3 + with: + version: v1.46.2 \ No newline at end of file diff --git a/.golangci.yml b/.golangci.yml index 1a14b3c..0db4715 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -44,4 +44,6 @@ linters: - gomoddirectives # Prohibits the use of replace statements - varnamelen # Forbids short var names - ireturn # Prevents returning interfaces - - forcetypeassert # Forces to assert types in tests \ No newline at end of file + - forcetypeassert # Forces to assert types in tests + - nonamedreturns # Disallows named returns + - exhaustruct # Forces all structs to be named \ No newline at end of file diff --git a/crypto/attachment_manual.go b/crypto/attachment_manual.go index 6e33c1f..89e5c29 100644 --- a/crypto/attachment_manual.go +++ b/crypto/attachment_manual.go @@ -148,7 +148,7 @@ func (keyRing *KeyRing) NewManualAttachmentProcessor( return attachmentProc, nil } -// readAll works a bit like io.ReadAll +// readAll works a bit like ioutil.ReadAll // but we can choose the buffer to write to // and we don't grow the slice in case of overflow. func readAll(buffer []byte, reader io.Reader) (int, error) { diff --git a/crypto/keyring_streaming_test.go b/crypto/keyring_streaming_test.go index c9a96de..390edb3 100644 --- a/crypto/keyring_streaming_test.go +++ b/crypto/keyring_streaming_test.go @@ -3,6 +3,7 @@ package crypto import ( "bytes" "io" + "io/ioutil" "reflect" "testing" @@ -65,7 +66,7 @@ func TestKeyRing_EncryptDecryptStream(t *testing.T) { if err == nil { t.Fatal("Expected an error while verifying the signature before reading the data, got nil") } - decryptedBytes, err := io.ReadAll(decryptedReader) + decryptedBytes, err := ioutil.ReadAll(decryptedReader) if err != nil { t.Fatal("Expected no error while reading the decrypted data, got:", err) } @@ -88,7 +89,7 @@ func TestKeyRing_EncryptDecryptStream(t *testing.T) { if err != nil { t.Fatal("Expected no error while calling decrypting stream with key ring, got:", err) } - decryptedBytes, err = io.ReadAll(decryptedReaderNoVerify) + decryptedBytes, err = ioutil.ReadAll(decryptedReaderNoVerify) if err != nil { t.Fatal("Expected no error while reading the decrypted data, got:", err) } @@ -188,7 +189,7 @@ func TestKeyRing_DecryptStreamCompatible(t *testing.T) { if err != nil { t.Fatal("Expected no error while calling decrypting stream with key ring, got:", err) } - decryptedBytes, err := io.ReadAll(decryptedReader) + decryptedBytes, err := ioutil.ReadAll(decryptedReader) if err != nil { t.Fatal("Expected no error while reading the decrypted data, got:", err) } @@ -257,7 +258,7 @@ func TestKeyRing_EncryptDecryptSplitStream(t *testing.T) { if err != nil { t.Fatal("Expected no error while decrypting split stream with key ring, got:", err) } - decryptedBytes, err := io.ReadAll(decryptedReader) + decryptedBytes, err := ioutil.ReadAll(decryptedReader) if err != nil { t.Fatal("Expected no error while reading the decrypted data, got:", err) } @@ -379,7 +380,7 @@ func TestKeyRing_DecryptSplitStreamCompatible(t *testing.T) { if err != nil { t.Fatal("Expected no error while decrypting split stream with key ring, got:", err) } - decryptedBytes, err := io.ReadAll(decryptedReader) + decryptedBytes, err := ioutil.ReadAll(decryptedReader) if err != nil { t.Fatal("Expected no error while reading the decrypted data, got:", err) } diff --git a/crypto/sessionkey_streaming_test.go b/crypto/sessionkey_streaming_test.go index 0115814..f597022 100644 --- a/crypto/sessionkey_streaming_test.go +++ b/crypto/sessionkey_streaming_test.go @@ -3,6 +3,7 @@ package crypto import ( "bytes" "io" + "io/ioutil" "reflect" "testing" @@ -55,7 +56,7 @@ func TestSessionKey_EncryptDecryptStream(t *testing.T) { if err != nil { t.Fatal("Expected no error while calling DecryptStream, got:", err) } - decryptedBytes, err := io.ReadAll(decryptedReader) + decryptedBytes, err := ioutil.ReadAll(decryptedReader) if err != nil { t.Fatal("Expected no error while reading the decrypted data, got:", err) } @@ -158,7 +159,7 @@ func TestSessionKey_DecryptStreamCompatible(t *testing.T) { if err != nil { t.Fatal("Expected no error while calling DecryptStream, got:", err) } - decryptedBytes, err := io.ReadAll(decryptedReader) + decryptedBytes, err := ioutil.ReadAll(decryptedReader) if err != nil { t.Fatal("Expected no error while reading the decrypted data, got:", err) }