func genToken(claims *JWTClaims) (string, error) {
    token := jwt.NewWithClaims(jwt.SigningMethodHS256, claims)
    signedToken, err := token.SignedString([]byte(Secret))
    if err != nil {
        return "", errors.New(ErrorServerBusy)
    }
    return signedToken, nil
}
generate jwt token
package main
import (
    "errors"
    "fmt"
    jwt "github.com/dgrijalva/jwt-go"
    "github.com/gin-gonic/gin"
    "net/http"
    "time"
)
const (
    ErrorServerBusy = "server is busy"
    ErrorReLogin = "relogin"
)
type JWTClaims struct {
    jwt.StandardClaims
    UserID int `json:"user_id"`
    Password string `json:"password"`
    Username string `json:"username"`
}
var (
    Secret = "123#111"   
    ExpireTime = 3600   
)
func main() {
    r := gin.Default()
    r.GET("/login/:username/:password", login)
    r.GET("/verify/:token", verify)
    r.GET("/refresh/:token", refresh)
    r.GET("/sayHello/:token", sayHello)
    _ = r.Run(":8000")
}