Skip to content

Commit

Permalink
Support Go 1.16 (#2)
Browse files Browse the repository at this point in the history
* update to support 1.16 (may need to drop 1.13)

* require 1.16 in order to compile

* disable cyclop linter

* let's try unpinning the lint action version
  • Loading branch information
aaronsky authored Feb 26, 2021
1 parent b1ce2cd commit 580a050
Show file tree
Hide file tree
Showing 11 changed files with 34 additions and 31 deletions.
11 changes: 8 additions & 3 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ jobs:
- windows-latest
go-version:
- 1.x
- 1.13.x
- 1.16.x
runs-on: ${{ matrix.platform }}
steps:
- uses: actions/checkout@v2
Expand Down Expand Up @@ -53,7 +53,12 @@ jobs:
steps:
- uses: actions/checkout@v2

- uses: actions/setup-go@v1
with:
go-version: '1.16'

- name: golangci-lint
uses: golangci/golangci-lint-action@v2
uses: golangci/golangci-lint-action@master
with:
version: v1.35
version: v1.37
skip-go-installation: true
14 changes: 8 additions & 6 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,16 @@ issues:
linters:
enable-all: true
disable:
- lll
- cyclop
- exhaustivestruct
- forbidigo
- funlen
- gofumpt
- gci
- gofumpt
- ifshort
- lll
- nlreturn
- testpackage
- exhaustivestruct
- wrapcheck
- paralleltest
- forbidigo
- testpackage
- thelper
- wrapcheck
5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ asc-go is a Go client library for accessing Apple's [App Store Connect API](http

## Usage

This project uses Go Modules.
This project uses Go Modules. It requires **Go 1.16 or higher**.

```go
import "github.com/cidertool/asc-go/asc"
Expand All @@ -35,6 +35,7 @@ You may find that the code snippet above will always fail due to a lack of autho

```go
import (
"os"
"time"

"github.com/cidertool/asc-go/asc"
Expand All @@ -48,7 +49,7 @@ func main() {
// A duration value for the lifetime of a token. App Store Connect does not accept a token with a lifetime of longer than 20 minutes
expiryDuration = 20*time.Minute
// The bytes of the PKCS#8 private key created on App Store Connect. Keep this key safe as you can only download it once.
privateKey = ioutil.ReadFile("path/to/key")
privateKey = os.ReadFile("path/to/key")

auth, err = asc.NewTokenConfig(keyID, issuerID, expiryDuration, privateKey)
if err != nil {
Expand Down
6 changes: 2 additions & 4 deletions asc/asc.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ import (
"encoding/json"
"fmt"
"io"
"io/ioutil"
"log"
"net/http"
"net/http/httputil"
Expand Down Expand Up @@ -411,7 +410,7 @@ func checkResponse(r *Response) error {
return nil
}

data, err := ioutil.ReadAll(r.Body)
data, err := io.ReadAll(r.Body)
erro := new(ErrorResponse)

if err == nil && data != nil {
Expand Down Expand Up @@ -510,8 +509,7 @@ func (e ErrorResponseError) String(level int) string {

// Close closes an open descriptor.
func closeDesc(c io.Closer) {
err := c.Close()
if err != nil {
if err := c.Close(); err != nil {
log.Fatal(err)
}
}
4 changes: 2 additions & 2 deletions asc/asc_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import (
"context"
"errors"
"fmt"
"io/ioutil"
"io"
"net/http"
"net/http/httptest"
"net/url"
Expand Down Expand Up @@ -186,7 +186,7 @@ func TestCheckBadResponse(t *testing.T) {
Method: "GET",
URL: &url.URL{},
},
Body: ioutil.NopCloser(strings.NewReader(`{
Body: io.NopCloser(strings.NewReader(`{
"errors": [
{
"code": "",
Expand Down
3 changes: 2 additions & 1 deletion asc/doc.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ and rotating JSON Web Tokens automatically. For example, the above snippet could
to look a little more like this:
import (
"os"
"time"
"github.com/cidertool/asc-go/asc"
Expand All @@ -66,7 +67,7 @@ to look a little more like this:
expiryDuration = 20*time.Minute
// The bytes of the PKCS#8 private key created on App Store Connect. Keep this key
// safe as you can only download it once.
privateKey = ioutil.ReadFile("path/to/key")
privateKey = os.ReadFile("path/to/key")
auth, err = asc.NewTokenConfig(keyID, issuerID, expiryDuration, privateKey)
if err != nil {
Expand Down
3 changes: 1 addition & 2 deletions asc/provisioning_certificates.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ import (
"errors"
"fmt"
"io"
"io/ioutil"
)

// ErrMissingCSRContent happens when CreateCertificate is provided a nil Reader for processing
Expand Down Expand Up @@ -144,7 +143,7 @@ func (s *ProvisioningService) CreateCertificate(ctx context.Context, certificate
return nil, nil, ErrMissingCSRContent
}

csrBytes, err := ioutil.ReadAll(csrContent)
csrBytes, err := io.ReadAll(csrContent)
if err != nil {
return nil, nil, err
}
Expand Down
10 changes: 4 additions & 6 deletions asc/upload_operation_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ import (
"crypto/rand"
"fmt"
"io"
"io/ioutil"
"net/http"
"os"
"testing"
Expand All @@ -35,7 +34,7 @@ import (
)

func TestMultipartUpload(t *testing.T) {
file, err := ioutil.TempFile("", "big_file")
file, err := os.CreateTemp("", "big_file")
if err != nil {
assert.FailNow(t, "temp file creation produced an error", err)
}
Expand Down Expand Up @@ -112,7 +111,7 @@ func TestMultipartUpload(t *testing.T) {
}

func TestUploadOperationChunk(t *testing.T) {
file, err := ioutil.TempFile("", "small_file")
file, err := os.CreateTemp("", "small_file")
if err != nil {
assert.FailNow(t, "temp file creation produced an error", err)
}
Expand Down Expand Up @@ -153,7 +152,7 @@ func TestUploadOperationChunk(t *testing.T) {
}

func TestUploadOperationUploadError_InvalidOperation(t *testing.T) {
file, err := ioutil.TempFile("", "big_file")
file, err := os.CreateTemp("", "big_file")
if err != nil {
assert.FailNow(t, "temp file creation produced an error", err)
}
Expand Down Expand Up @@ -190,8 +189,7 @@ func TestUploadOperationUploadError_InvalidOperation(t *testing.T) {

// rmFile closes an open descriptor.
func rmFile(f *os.File) {
err := os.Remove(f.Name())
if err != nil {
if err := os.Remove(f.Name()); err != nil {
fmt.Println(err)
}
}
4 changes: 2 additions & 2 deletions examples/util/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ import (
"flag"
"fmt"
"io"
"io/ioutil"
"log"
"os"
"time"

"github.com/cidertool/asc-go/asc"
Expand All @@ -47,7 +47,7 @@ func TokenConfig() (auth *asc.AuthTransport, err error) {
secret = []byte(*privateKey)
} else if *privateKeyPath != "" {
// Read private key file as []byte
secret, err = ioutil.ReadFile(*privateKeyPath)
secret, err = os.ReadFile(*privateKeyPath)
if err != nil {
return nil, err
}
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module github.com/cidertool/asc-go

go 1.13
go 1.16

require (
github.com/cenkalti/backoff/v4 v4.1.0
Expand Down
3 changes: 1 addition & 2 deletions test/integration/asc_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ package integration

import (
"fmt"
"io/ioutil"
"os"
"time"

Expand Down Expand Up @@ -58,7 +57,7 @@ func tokenConfig() *asc.AuthTransport {
privateKey = []byte(key)
} else if keyPath := os.Getenv(envPrivateKeyPath); keyPath != "" {
// Read private key file as []byte
privateKey, err = ioutil.ReadFile(keyPath)
privateKey, err = os.ReadFile(keyPath)
if err != nil {
fmt.Println(err)
return nil
Expand Down

0 comments on commit 580a050

Please sign in to comment.