I'm running go1.6 and am getting the follow error when running "go build" in 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)
Project structure:
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"
)
Your main.go
file needs to be inside a workspace (that is, inside gopath) for its dependencies to be vendored. As a test, try putting your main.go
inside a fake path and see if the vendored deps are found:
$GOPATH/src/
example.com/
main.go
vendor/
github.com/
spf13/viper/
gizak/termui/
In general, you don't want to store any code in your gopath outside its root src
directory. That is, you should echo the structure that go get
would use when creating the directories.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With