dongqianzong4275 2016-03-20 21:27
浏览 65

无法解决供应商目录中的依赖性

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"
)
  • 写回答

1条回答 默认 最新

  • dse323222 2016-03-21 02:11
    关注

    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.

    评论

报告相同问题?

悬赏问题

  • ¥15 echarts动画效果失效的问题。官网下载的例子。
  • ¥60 许可证msc licensing软件报错显示已有相同版本软件,但是下一步显示无法读取日志目录。
  • ¥15 Attention is all you need 的代码运行
  • ¥15 一个服务器已经有一个系统了如果用usb再装一个系统,原来的系统会被覆盖掉吗
  • ¥15 使用esm_msa1_t12_100M_UR50S蛋白质语言模型进行零样本预测时,终端显示出了sequence handled的进度条,但是并不出结果就自动终止回到命令提示行了是怎么回事:
  • ¥15 前置放大电路与功率放大电路相连放大倍数出现问题
  • ¥30 关于<main>标签页面跳转的问题
  • ¥80 部署运行web自动化项目
  • ¥15 腾讯云如何建立同一个项目中物模型之间的联系
  • ¥30 VMware 云桌面水印如何添加