cannot use r (variable of type *”vendor/github.com/gorilla/mux”.Router) as *”github.com/gorilla/mux”.Router value in argument [closed]

I’m getting this error in the code

cannot use r (variable of type *"vendor/github.com/gorilla/mux".Router) as *"github.com/gorilla/mux".Router value in argument to routes.RegisterBookStoreRoutes
func main() {
    r := mux.NewRouter()
    routes.RegisterBookStoreRoutes(r)
    http.Handle("/", r)
    log.Fatal(http.ListenAndServe("localhost:8010", r))
}

This is my Import clause, it doesn’t have vendor/ in it.

import (
    "log"
    "net/http"
    "github.com/gorilla/mux"
    "github.com/shetaanshu/go-bookstore/pkg/routes"
)

how to debug the error?

  • 2

    You seem to be importing gorilla mux with vendor prefix.

    – 

  • 3

    Do not put “vendor/” in the import path of the package in the import clause. An import path is not a path on the filesystem. Packages under the vendor/ folder are picked up by the go tooling automatically.

    – 

Leave a Comment