cannot find package “github.com/gorilla/mux” in any of:

后端 未结 6 919
慢半拍i
慢半拍i 2021-02-13 04:15

I use command go get github.com/gorilla/mux. I made http server using Golang, and I run this program :

package main

import (
    \"fmt\"
    \"htm         


        
相关标签:
6条回答
  • 2021-02-13 04:31

    I wish this helpful. You may off the 'mod'.

    $ export GO111MODULE=off
    
    0 讨论(0)
  • 2021-02-13 04:32

    Try go build /Users/imac/go/src/project

    because I see you try to use go build under /Users/imac/go/src

    0 讨论(0)
  • 2021-02-13 04:35

    Just remove quotes like this:

    go get github.com/gorilla/mux
    
    0 讨论(0)
  • 2021-02-13 04:35

    I try to remove github.com/gorilla and github.com/peterbourgon directory, then, retry: make, it works.

    <pre>
    fail log:
    
    
    mac@user:~/TempPlace/temp/ngrok% make
    go fmt ngrok/...
    go get github.com/jteeuwen/go-bindata
    GOOS="" GOARCH="" go install github.com/jteeuwen/go-bindata/go-bindata
    bin/go-bindata -nomemcopy -pkg=assets -tags=debug \
    		-debug=true \
    		-o=src/ngrok/client/assets/assets_debug.go \
    		assets/client/...
    go get github.com/jteeuwen/go-bindata
    GOOS="" GOARCH="" go install github.com/jteeuwen/go-bindata/go-bindata
    bin/go-bindata -nomemcopy -pkg=assets -tags=debug \
    		-debug=true \
    		-o=src/ngrok/server/assets/assets_debug.go \
    		assets/server/...
    go get -tags 'debug' -d -v ngrok/...
    src/ngrok/server/config.go:16:2: no Go files in /Users/apple/TempPlace/temp/ngrok/src/github.com/gorilla/mux
    src/ngrok/server/config.go:17:2: no Go files in /Users/apple/TempPlace/temp/ngrok/src/github.com/peterbourgon/diskv
    make: *** [deps] Error 1
    
    
    success log:
    
    
    mac@user:~/TempPlace/temp/ngrok% make
    go fmt ngrok/...
    go get github.com/jteeuwen/go-bindata
    GOOS="" GOARCH="" go install github.com/jteeuwen/go-bindata/go-bindata
    bin/go-bindata -nomemcopy -pkg=assets -tags=debug \
    		-debug=true \
    		-o=src/ngrok/client/assets/assets_debug.go \
    		assets/client/...
    go get github.com/jteeuwen/go-bindata
    GOOS="" GOARCH="" go install github.com/jteeuwen/go-bindata/go-bindata
    bin/go-bindata -nomemcopy -pkg=assets -tags=debug \
    		-debug=true \
    		-o=src/ngrok/server/assets/assets_debug.go \
    		assets/server/...
    go get -tags 'debug' -d -v ngrok/...
    github.com/gorilla/websocket (download)
    github.com/gorilla/mux (download)
    src/ngrok/server/config.go:17:2: no Go files in /Users/apple/TempPlace/temp/ngrok/src/github.com/peterbourgon/diskv
    make: *** [deps] Error 1
    mac@user:~/TempPlace/temp/ngrok% make
    go fmt ngrok/...
    go get github.com/jteeuwen/go-bindata
    GOOS="" GOARCH="" go install github.com/jteeuwen/go-bindata/go-bindata
    bin/go-bindata -nomemcopy -pkg=assets -tags=debug \
    		-debug=true \
    		-o=src/ngrok/client/assets/assets_debug.go \
    		assets/client/...
    go get github.com/jteeuwen/go-bindata
    GOOS="" GOARCH="" go install github.com/jteeuwen/go-bindata/go-bindata
    bin/go-bindata -nomemcopy -pkg=assets -tags=debug \
    		-debug=true \
    		-o=src/ngrok/server/assets/assets_debug.go \
    		assets/server/...
    go get -tags 'debug' -d -v ngrok/...
    github.com/peterbourgon/diskv (download)
    github.com/google/btree (download)
    go install -tags 'debug' ngrok/main/ngrok
    go install -ldflags "-s" -tags 'debug' ngrok/main/ngrokd
    
    </pre>

    0 讨论(0)
  • 2021-02-13 04:38

    Could you try this steps to debug it:

    1. ls -l /usr/local/go/src/github.com | grep gorilla
    2. cd $GOPATH

      go list ... | grep gorilla

    3. if you din't see gorilla in the above two command, then you need to install it: go get -v -u github.com/gorilla/mux

    Please run this: export PATH=$PATH:$GOPATH/bin

    How about running go run main.go ? is that working, if yes you should be able to do go build from your project path.

    0 讨论(0)
  • 2021-02-13 04:40

    If you are using VS Code as your IDE and facing this problem:

    VS Code uses $HOME/go as your default GOPATH - if you export another GOPATH you running into this trouble.

    How to solve:

    1. Use the VS Code internal terminal and navigate to your project folder: cd prjectFolder. Type go env and check if the GOPATH entry is the same as you get when you use cmd+t and then >Go: Current GOPATH
    2. If it doesn't fit, add in your user settings: "go.gopath": "/some/path" where /some/path is the same path you export in you shell, zsh and so on.

    Hope this helps.

    0 讨论(0)
提交回复
热议问题