我正在运行go1.6并且在运行" go build"时遇到跟随错误在GOPATH(/ Users / bweidlich / Projects / go)
main.go:6:2: cannot find package "github.com/spf13/viper" in any of:
/usr/local/go/src/github.com/spf13/viper (from $GOROOT)
/Users/bweidlich/Projects/go/src/github.com/spf13/viper (from $GOPATH)
项目结构:
bin/
glide.lock
glide.yaml
go.iml
logs/
main.go
pkg/
src/
vendor/
github.com/
deckarep/gosx-notifier
spf13/viper
gizak/termui
main.go
package main
import (
"fmt"
"github.com/gizak/termui" <--- doesn't resolve
"github.com/spf13/viper" <--- doesn't resolve
"log"
"bweidlich/dash"
"net/http"
"os"
"os/exec"
"time"
)
答案 0 :(得分:5)
您的(let [numbers (range 1 4)]
(for [n numbers
m numbers
:when (not= n m)]
(+ n m)))
;; -> (3 4 3 5 4 5)
文件需要位于工作区内(即gopath内部)才能销售其依赖项。作为测试,尝试将main.go
置于假路径中,看看是否找到了销售代码:
main.go
通常,您不希望在其根$GOPATH/src/
example.com/
main.go
vendor/
github.com/
spf13/viper/
gizak/termui/
目录之外的gopath中存储任何代码。也就是说,您应该回应src
在创建目录时将使用的结构。