I have go code which looks like this
package services
import (
"net/http"
"strings"
"github.com/gin-gonic/gin"
"github.com/irohitb/EmpAdmin/backend/config"
"github.com/irohitb/EmpAdmin/backend/middleware"
"github.com/supabase/postgrest-go"
)
func GetAllUsers(env *config.Env, db *postgrest.Client, group *gin.RouterGroup) {
group.GET("/:services", func (router *gin.Context) {
services := strings.Split(router.Param("service"), ",")
user, exists := router.Get("user")
if !exists {
router.AbortWithStatusJSON(http.StatusInternalServerError, gin.H{"error": "user information not found in context"})
return
}
userToken, exists := user.(*middleware.UserToken)
if exists {
workspaceId := userToken.User.WorkspaceID
}
})
}
Here VS code complains about
"github.com/irohitb/EmpAdmin/backend/middleware"
imported but not used error.
which I am using here
*middleware.UserToken
Here is how my middleware looks
package middleware
import (
"net/http"
"github.com/dgrijalva/jwt-go"
"github.com/gin-gonic/gin"
"github.com/irohitb/EmpAdmin/backend/domain"
)
type UserToken struct {
jwt.StandardClaims
User domain.UserToken
}