【发布时间】:2018-11-17 09:26:37
【问题描述】:
我的结构项目
currency-quote-api -
|
|- scraping/ file.go
|- api/ file.go
|- tests/ test.go
|- main.go
当我在 travis CI 中运行测试时,出现以下错误
tests/scraping_test.go:4:2: cannot find package "currency-quote-api/scraping" in any of:
/home/travis/.gimme/versions/go1.10.2.linux.amd64/src/currency-quote-api/scraping (from $GOROOT)
/home/travis/gopath/src/github.com/matheussilva97/currency-quote-api/Godeps/_workspace/src/currency-quote-api/scraping (from $GOPATH)
/home/travis/gopath/src/currency-quote-api/scraping
我做错了什么?
我的 .travis.yml
sudo: false
language: go
go:
- 1.10.2
notifications:
email: false
before_script:
- go get github.com/gorilla/mux
- go get github.com/PuerkitoBio/goquery
script:
- go test -v ./tests/
【问题讨论】:
-
您的项目源代码在GOPATH下似乎不可用。
-
这是 Travis 独有的问题吗?你如何在你的机器上编译它?另外:您的包裹布局看起来很可疑。你确定你在这里做什么?
-
我不能这样配置我的包?我需要将所有文件放在项目的根目录下吗?我只是运行 main.go 并工作,我在 import 中导入其他包,比如这个 import("currency-quote-api/api")
-
阅读如何编写 Go 代码并逐字逐句地坚持下去。
-
Go(特别是 go cli 工具)非常固执己见。看起来您试图在没有真正了解您所做的方式或所做的事情的情况下偏离标准。 golang.org/doc/code.html