drvonr6573 2013-11-14 02:39
浏览 123
已采纳

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

I'm trying to install my Go test package, but I keep getting this error:

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

Here's my code:

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))
}

My GOROOT is pointing to Go's installation root, and GOPATH to my workspace root.

EDIT

Here's the output of 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
  • 写回答

1条回答 默认 最新

  • douwuying4709 2013-11-14 02:59
    关注

    I noticed your directory name D:\Développement\golang\src\github.com\jpmonette\hello has non ascii character. I am not sure if Go handles these properly.

    Alex

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥20 我想使用一些网络协议或者部分协议也行,主要想实现类似于traceroute的一定步长内的路由拓扑功能
  • ¥30 深度学习,前后端连接
  • ¥15 孟德尔随机化结果不一致
  • ¥15 apm2.8飞控罗盘bad health,加速度计校准失败
  • ¥15 求解O-S方程的特征值问题给出边界层布拉休斯平行流的中性曲线
  • ¥15 谁有desed数据集呀
  • ¥20 手写数字识别运行c仿真时,程序报错错误代码sim211-100
  • ¥15 关于#hadoop#的问题
  • ¥15 (标签-Python|关键词-socket)
  • ¥15 keil里为什么main.c定义的函数在it.c调用不了