Skip to content
Node: jwt.sign(payload, secret, { expiresIn })github.com/sahilkhaire/gox/jwt

Sign

Overview

Sign builds a signed JWT from claims (jwt.sign).

If you are coming from Node.js, the closest pattern is jwt.sign(payload, secret, { expiresIn }).

Signature

go
func Sign(claims jwtlib.MapClaims, secret []byte, opts *SignOptions) (string, error)

Compare: Node.js · Standard Go · gox

js
const token = jwt.sign(payload, secret);
go
// use golang-jwt directly
go
import "github.com/sahilkhaire/gox/jwt"

token, err := jwt.Sign(claims, secret, jwt.SignOptions{})

Example

go
import "github.com/sahilkhaire/gox/jwt"

token, err := jwt.Sign(claims, secret, jwt.SignOptions{})

Tips

Import github.com/sahilkhaire/gox/jwt and call Sign directly. See the comparison below for the standard library equivalent.

Standard library alternative

Use the standard library directly:

go
// use golang-jwt directly

Back to jwt package overview

MIT Licensed · Built for Node.js developers moving to Go