Changed example to use Output test.

This commit is contained in:
Jamie Stackhouse 2015-07-22 13:48:42 -03:00
parent aa6ac13a18
commit 6f536a0d2d
1 changed files with 5 additions and 5 deletions

View File

@ -2,6 +2,7 @@ package jwt_test
import ( import (
"fmt" "fmt"
"time"
"github.com/dgrijalva/jwt-go" "github.com/dgrijalva/jwt-go"
) )
@ -18,18 +19,17 @@ func ExampleParse(myToken string, myLookupKey func(interface{}) (interface{}, er
} }
} }
func ExampleNew(mySigningKey []byte) (string, error) { func ExampleNew() {
// Create the token // Create the token
token := jwt.New(jwt.SigningMethodRS256) token := jwt.New(jwt.SigningMethodRS256)
// Set some claims // Set some claims
claims := token.Claims.(jwt.MapClaim) claims := token.Claims.(jwt.MapClaim)
claims["foo"] = "bar" claims["foo"] = "bar"
claims["exp"] = 15000 claims["exp"] = time.Unix(0, 0).Add(time.Hour * 1).Unix()
// Sign and get the complete encoded token as a string fmt.Printf("%v\n", claims)
tokenString, err := token.SignedString(mySigningKey) //Output: map[foo:bar exp:3600]
return tokenString, err
} }
func ExampleNewWithClaims(mySigningKey []byte) (string, error) { func ExampleNewWithClaims(mySigningKey []byte) (string, error) {