mux.go:12: 找不到导入:“github.com/gorilla/context”`

我正在尝试安装我的 Go 测试包,但我不断收到此错误:


D:\Developpement\golang\src\github.com\gorilla\mux\mux.go:12: can't find import: "github.com/gorilla/context"


这是我的代码:


package main


import (

    "github.com/gorilla/pat"

    "net/http"

)


func main() {

  mux := pat.New()

  mux.Get("/user/:name/profile", http.HandlerFunc(profile))


  http.Handle("/", mux)


  log.Println("Listening...")

  http.ListenAndServe(":3000", nil)

}


func profile(w http.ResponseWriter, r *http.Request) {

  params := r.URL.Query()

  name := params.Get(":name")

  w.Write([]byte("Hello " + name))

}

MyGOROOT指向 Go 的安装根目录和GOPATH我的工作区根目录。


编辑


这是输出go env:


D:\Développement\golang\src\github.com\jpmonette\hello>go env

set GOARCH=386

set GOBIN=

set GOCHAR=8

set GOEXE=.exe

set GOHOSTARCH=386

set GOHOSTOS=windows

set GOOS=windows

set GOPATH=D:\Développement\golang\

set GORACE=

set GOROOT=C:\Go

set GOTOOLDIR=C:\Go\pkg\tool\windows_386

set CC=gcc

set GOGCCFLAGS=-g -O2 -m32 -mthreads

set CGO_ENABLED=1


犯罪嫌疑人X
浏览 180回答 1
1回答
打开App,查看更多内容
随时随地看视频慕课网APP

相关分类

Go