Skip to content

Commit

Permalink
migrate to Go 1.13
Browse files Browse the repository at this point in the history
  • Loading branch information
NexoMichael committed Oct 27, 2019
1 parent eb4a5b8 commit c065858
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 21 deletions.
13 changes: 1 addition & 12 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,12 +1 @@
# Binaries for programs and plugins
*.exe
*.exe~
*.dll
*.so
*.dylib

# Test binary, build with `go test -c`
*.test

# Output of the go coverage tool, specifically when used with LiteIDE
*.out
./jwt
6 changes: 3 additions & 3 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
module github.com/NexoMichael/jwt

require (
github.com/pkg/errors v0.8.0
)
require github.com/stretchr/testify v1.4.0

go 1.13
11 changes: 11 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
github.com/davecgh/go-spew v1.1.0 h1:ZDRjVQ15GmhC3fiQ8ni8+OwkZQO4DARzQgrnXU1Liz8=
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
github.com/stretchr/testify v1.4.0 h1:2E4SXV/wtOkTonXsotYi4li6zVWxYlZuYNCXe9XRJyk=
github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/yaml.v2 v2.2.2 h1:ZCJp+EgiOT7lHqUV2J862kp8Qj64Jo6az82+3Td9dZw=
gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
11 changes: 5 additions & 6 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,12 @@ package main // import "github.com/NexoMichael/jwt"
import (
"encoding/base64"
"encoding/json"
"errors"
"fmt"
"io"
"os"
"strings"
"time"

"github.com/pkg/errors"
)

var helpMsg = `jwt - command line JWT token parser
Expand Down Expand Up @@ -96,11 +95,11 @@ func parseToken(tokenString string) (token, error) {
}

if err := parsePart(&t.header, parts[0]); err != nil {
return t, errors.Wrap(err, "failed to parse token header")
return t, fmt.Errorf("failed to parse token header: %v", err)
}

if err := parsePart(&t.body, parts[1]); err != nil {
return t, errors.Wrap(err, "failed to parse token body")
return t, fmt.Errorf("failed to parse token body: %v", err)
}

t.signature = parts[2]
Expand All @@ -119,11 +118,11 @@ func decodePart(part string) ([]byte, error) {
func parsePart(dst interface{}, part string) (err error) {
var src []byte
if src, err = decodePart(part); err != nil {
return errors.Wrap(err, "failed to decode token part")
return fmt.Errorf("failed to decode token part: %v", err)
}

if err = json.Unmarshal(src, dst); err != nil {
return errors.Wrap(err, "failed to unmarshal token part")
return fmt.Errorf("failed to unmarshal token part: %v", err)
}
return nil
}
Expand Down

0 comments on commit c065858

Please sign in to comment.