简体   繁体   English

Github 操作在存储库中找不到 package

[英]Github actions can't find package within repository

When setting up a github actions pipeline, I can't get it to find packages that are within my repository, and the test fails because it's missing packages.在设置 github 操作管道时,我无法让它找到我的存储库中的包,并且测试失败,因为它缺少包。

What happens is that it clones the repo someplace but doesn't include the cloned repo's directories to look for packages.发生的情况是它在某个地方克隆了 repo,但不包括克隆的 repo 的目录来查找包。 That fails because I am importing packages from within that repo in my code.那失败了,因为我在我的代码中从该仓库中导入包。

I believe my directory structure is sound because I have no trouble testing and building locally:我相信我的目录结构是合理的,因为我在本地测试和构建没有问题:

.                                                                                                                                                           │
├── extractors                                                                                                                                              │
│   ├── fip.go                                                                                                                                              │
│   └── fip_test.go                                                                                                                                         │
├── fixtures                                                                                                                                                │
│   └── fip                                                                                                                                                 │
│       ├── bad_req.json                                                                                                                                    │
│       └── history_response.json                                                                                                                           │
├── .github                                                                                                                                                 │
│   └── workflows                                                                                                                                           │
│       └── go_test.yml                                                                                                                                     │
├── main.go                                                                                                                                                 │
├── Makefile                                                                                                                                                │
├── playlist                                                                                                                                                │
│   └── playlist.go                                                                                                                                         │
├── README.md                                                                                                                                                                                                                                                                                          │
└── utils                                                                                                                                                   │
    ├── logger                                                                                                                                              │
    │   └── logger.go                                                                                                                                       │
    └── mocks                                                                                                                                               │
        └── server.go                                                                                                                                       │
                                                                                                                                                            │

View the run here 在这里查看运行

How do I make Github actions look for the package within the cloned dir as well?如何使 Github 动作也在克隆目录中查找 package ?

Make sure to run go mod init MODULE_NAME (if the project is outside GOROOT or GOPATH) or just simply go mod init (if the project is inside GOROOT or GOPATH).确保运行go mod init MODULE_NAME (如果项目在 GOROOT 或 GOPATH 之外)或只是简单地go mod init (如果项目在 GOROOT 或 GOPATH 内)。 The command should be run on the root folder of your project.该命令应在项目的根文件夹中运行。 This would create a go.mod file that would enable go resolve your packages.这将创建一个go.mod文件,该文件将启用go解析您的包。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM