func GenerateJWT(id, duration int64, secret string) string {

	token := jwt.NewWithClaims(jwt.SigningMethodHS256, jwt.StandardClaims{
		Id:        strconv.FormatInt(id, 10),
		ExpiresAt: time.Now().AddDate(0, 0, int(duration)).Unix(),
	})

	// time.Now().Add(time.Hour * 24).Unix()
	// token := jwt.New(jwt.SigningMethodHS256)
	// token.Claims["admin"] = true

	tokenString, err := token.SignedString([]byte(secret))
	if err != nil {
		panic(fmt.Errorf("generateJWT failed: %v", err))
	}

	return tokenString
}
// use standardClaims, only save id
use standardClaims, only save id
// use standardClaims only save id
func GenerateJWT(id, duration int64, secret string) string {
	token := jwt.NewWithClaims(jwt.SigningMethodHS256, jwt.StandardClaims{
		Id:        strconv.FormatInt(id, 10),
		ExpiresAt: time.Now().AddDate(0, 0, int(duration)).Unix(),
	})
	tokenString, err := token.SignedString([]byte(secret))
	if err != nil {
		panic(fmt.Errorf("generateJWT failed: %v", err))
	}
	return tokenString
}
func GenerateJWT ( id , duration int64 , secret string ) string { token := jwt . NewWithClaims ( jwt . SigningMethodHS256 , jwt . StandardClaims { Id : strconv . FormatInt ( id , 10 ) , ExpiresAt : time . Now ( ) . AddDate ( 0 , 0 , int ( duration ) ) . Unix ( ) , } ) tokenString , err := token . SignedString ( [ ] byte ( secret ) ) if err != nil { panic ( fmt . Errorf ( " " , err ) ) } return tokenString }
use standardClaims, only save id
use standardClaims only save id
// time.Now().Add(time.Hour * 24).Unix() // token := jwt.New(jwt.SigningMethodHS256) // token.Claims["admin"] = true