package utils import "github.com/gin-gonic/gin" func SetUserId(c *gin.Context, userId int64) { if c.Keys == nil { c.Keys = make(map[string]interface{}) } c.Keys["userId"] = userId } func GetUserId(c *gin.Context) int64 { val, ok := c.Get("userId") if !ok { return 0 } return val.(int64) }