我的戈罗特之路:- C:\Go
我已将GOPATH设置为:- C:\Users\kunal\go
但是当我在VS代码中导入模块(如github.com/gorilla/mux)时。VS代码提示我这个错误:-
could not import github.com/gorilla/mux (cannot find package "github.com/gorilla/mux" in any of C:\Go\src\github.com\gorilla\mux (from $GOROOT) C\src\github.com\gorilla\mux (from $GOPATH)
当我在Cygwin中使用以下命令时:
$ go get github.com/gorilla/mux
我收到以下错误:
# cd .; git clone https://github.com/gorilla/mux C:\cygwin64\home\USER\Go\src\github.com\gorilla\mux
Cloning into 'C:\cygwin64\home\USER\Go\src\github.com\gorilla\mux'...
fatal: Invalid path '/home/USER/C:\cygwin64\home\USER\Go\
我想在中为使用Gorilla从请求URL读取变量的处理程序编写测试。
我从中了解到,您可以创建一个假上下文并请求用于测试。
我在测试中直接调用处理程序,但是处理程序没有像预期的那样看到路径参数。
func TestRouter(t *testing.T) {
inst, _ := aetest.NewInstance(nil) //ignoring error for brevity
defer inst.Close()
//tried adding this line because the test would not work with or without it
htt
所以我有下面的代码
package main
import (
"github.com/gorilla/mux"
)
func main() {
router := mux.NewRouter()
}
当我运行时,它会给出以下错误binapi.go:4:2: no required module provides package github.com/gorilla/mux; to add it: go get github.com/gorilla/mux,如何修复此错误?我已经以各种可能的方式运行go get github.com/gorilla/mux命令,
我正在使用gorilla mux设置动态路由,下面是routes.go代码 type Route struct {
Name string
Method string
Pattern string
Queries []string
HandlerFunc http.HandlerFunc
}
type Routes []Route
var vers = os.Getenv("API_VERSION")
var baseURL = "/api/" + vers + "/&