dpdkqls6399 2016-10-22 04:18
浏览 90
已采纳

使用本地包的部署构建失败,并且“导入路径不是以主机名开头”

I'm new to Go, and I imagine this is an obvious situation for anyone who's worked with Go deployment in the past. In the most TL;DR sense, I built out a demo project from Scotch.IO for a simple todo list using Go (https://scotch.io/tutorials/create-a-single-page-app-with-go-echo-and-vue), and it works flawlessly on my machine, but it breaks in CircleCI when it attempts to import locally defined packages:

  import (
     "database/sql"
     "net/http"
     "strconv"

     "go-todo/models" // <- This

     "github.com/labstack/echo"
  )

I know there's no real reason to deploy an app like this, but I'd like to understand it better before diving into larger projects where deployment is essential. The logs at the breakpoint read:

package go-todo/handlers: unrecognized import path "go-todo/handlers" (import path does not begin with hostname)
package go-todo/models: unrecognized import path "go-todo/models" (import path does not begin with hostname)

And while I grasp that the path is incomplete from a remote environment perspective, I also know that relative paths won't fix it, and I have to assume there's some environmental variable that my ignorance is making me blind to in this context.

It's also worth noting that all of the go get calls for remote packages play nicely as expected.

Any help will be greatly appreciated. Refining my google searches is just bringing back the same stack of seemingly unrelated questions.

  • 写回答

1条回答 默认 最新

  • dougaopu7938 2016-10-22 08:20
    关注

    You need to have all imported libraries in your $GOPATH (external libs) or $GOROOT (std lib)

    The go get command can fetch libraries from remote and put them in your $GOPATH

    So if you go get github.com/labstack/echo it fetches the library from the URL and places it in $GOPATH/github.com/labstack/echo locally.

    This is not possible for the library go-todo/models to be fetched remotely like that, so you need to make sure in your CI that it is copied and made available locally at $GOPATH/go-todo/models.

    Or you can try vendoring.

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

报告相同问题?

悬赏问题

  • ¥15 请问有会的吗,用MATLAB做
  • ¥15 phython如何实现以下功能?查找同一用户名的消费金额合并—
  • ¥15 ARIMA模型时间序列预测用pathon解决
  • ¥15 孟德尔随机化怎样画共定位分析图
  • ¥18 模拟电路问题解答有偿速度
  • ¥15 CST仿真别人的模型结果仿真结果S参数完全不对
  • ¥15 误删注册表文件致win10无法开启
  • ¥15 请问在阿里云服务器中怎么利用数据库制作网站
  • ¥60 ESP32怎么烧录自启动程序,怎么查看客户esp32板子上程序及烧录地址
  • ¥50 html2canvas超出滚动条不显示