From d92f3df063295d32043cd00582c302f177379e35 Mon Sep 17 00:00:00 2001 From: Matt Gaunt Date: Mon, 12 Jun 2017 13:49:24 -0700 Subject: [PATCH 1/6] Adding travis support --- .travis.yml | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 .travis.yml diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 0000000..c806627 --- /dev/null +++ b/.travis.yml @@ -0,0 +1,16 @@ +language: go + +go: + - 1.6.x + - 1.7.x + - master + +before_install: + - go get github.com/golang/lint/golint + +install: + - cd webpush + - golint + - gofmt -d -e -s . + - go vet + - go test -v From 9ae07da1bf000e930ec0fddc9a24244df72f9eb2 Mon Sep 17 00:00:00 2001 From: Matt Gaunt Date: Mon, 12 Jun 2017 13:56:05 -0700 Subject: [PATCH 2/6] Fix travis errors --- .travis.yml | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index c806627..9315262 100644 --- a/.travis.yml +++ b/.travis.yml @@ -10,7 +10,11 @@ before_install: install: - cd webpush + + # golint returns a zero code regardless of errors. This prints out messages.. - golint - - gofmt -d -e -s . + # .... this errors if any output is printed to stdout + - test -z "$$(golint .)" + - go vet - go test -v From 747e510bac3fcd99762b5a5253aeb329269e4c91 Mon Sep 17 00:00:00 2001 From: Matt Gaunt Date: Mon, 12 Jun 2017 13:56:35 -0700 Subject: [PATCH 3/6] Adding 1.8 explicitly to travis setup --- .drone.yml | 10 ---------- .travis.yml | 1 + 2 files changed, 1 insertion(+), 10 deletions(-) delete mode 100644 .drone.yml diff --git a/.drone.yml b/.drone.yml deleted file mode 100644 index d68c635..0000000 --- a/.drone.yml +++ /dev/null @@ -1,10 +0,0 @@ -build: - image: golang:1.6.2 - commands: - - go get -d ./... - - go get github.com/golang/lint/golint - - cd webpush - - golint - - gofmt -d -e -s . - - go vet - - go test diff --git a/.travis.yml b/.travis.yml index 9315262..70e5c51 100644 --- a/.travis.yml +++ b/.travis.yml @@ -3,6 +3,7 @@ language: go go: - 1.6.x - 1.7.x + - 1.8.x - master before_install: From bbacf1e0b21e3e74605ab9e5bf4db8ee828f50d6 Mon Sep 17 00:00:00 2001 From: Matt Gaunt Date: Mon, 12 Jun 2017 13:59:07 -0700 Subject: [PATCH 4/6] Tidier exit status --- .travis.yml | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/.travis.yml b/.travis.yml index 70e5c51..7801390 100644 --- a/.travis.yml +++ b/.travis.yml @@ -12,10 +12,7 @@ before_install: install: - cd webpush - # golint returns a zero code regardless of errors. This prints out messages.. - - golint - # .... this errors if any output is printed to stdout - - test -z "$$(golint .)" + - golint -set_exit_status - go vet - go test -v From cb51ea4bad98926c97a1ff5bd520836f56565b7b Mon Sep 17 00:00:00 2001 From: Matt Gaunt Date: Mon, 12 Jun 2017 14:05:59 -0700 Subject: [PATCH 5/6] Fixing linting errors --- webpush/encrypt.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/webpush/encrypt.go b/webpush/encrypt.go index 32cbb35..d685849 100644 --- a/webpush/encrypt.go +++ b/webpush/encrypt.go @@ -147,7 +147,7 @@ type EncryptionResult struct { func Encrypt(sub *Subscription, message string) (*EncryptionResult, error) { plaintext := []byte(message) if len(plaintext) > maxPayloadLength { - return nil, fmt.Errorf("Payload is too large. The max number of bytes is %d, input is %d bytes.", maxPayloadLength, len(plaintext)) + return nil, fmt.Errorf("Payload is too large. The max number of bytes is %d, input is %d bytes", maxPayloadLength, len(plaintext)) } if len(sub.Key) == 0 { @@ -301,7 +301,7 @@ func encrypt(plaintext, key, nonce []byte) ([]byte, error) { func sharedSecret(curve elliptic.Curve, pub, priv []byte) ([]byte, error) { publicX, publicY := elliptic.Unmarshal(curve, pub) if publicX == nil { - return nil, fmt.Errorf("Couldn't unmarshal public key. Not a valid point on the curve.") + return nil, fmt.Errorf("Couldn't unmarshal public key. Not a valid point on the curve") } x, _ := curve.ScalarMult(publicX, publicY, priv) return x.Bytes(), nil From 1a8c5f15a2f645b06e8b5791d6ba3f02492af10a Mon Sep 17 00:00:00 2001 From: Matt Gaunt Date: Tue, 13 Jun 2017 12:26:17 -0700 Subject: [PATCH 6/6] Review comments --- .travis.yml | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/.travis.yml b/.travis.yml index 7801390..d7163e4 100644 --- a/.travis.yml +++ b/.travis.yml @@ -6,13 +6,11 @@ go: - 1.8.x - master -before_install: +before_script: - go get github.com/golang/lint/golint -install: +script: - cd webpush - - golint -set_exit_status - - go vet - go test -v