首页 > 解决方案 > 在 golang 迁移中找不到 bitbucket 包(go modules)

问题描述

我正在更新一个谷歌应用引擎应用,所以它使用 golang 1.12。

我被迫使用 go 模块。因此,我正在尝试修改项目来这样做。我更新到 .yml 文件以反映这一点:

runtime: go112
...
- url: /.*
  script: auto

由于我不是原始开发人员,因此我无法使其正常工作。它使用私人比特桶。我使用 ssh 密钥进行身份验证,因此 golang 可以在正确调用 git 时获取包。

运行“go mod tidy”时我仍然遇到问题:

bitbucket.org/nxtlab/sticktothebrand/app imports
    bitbucket.org/nxtlab/sticktothebrand: cannot find module providing package bitbucket.org/nxtlab/sticktothebrand: invalid bitbucket.org/ import path "bitbucket.org/nxtlab"
bitbucket.org/nxtlab/sticktothebrand/gopath/src/bitbucket.org/nxtlab/sticktothebrand imports
    bitbucket.org/nxtlab/sticktothebrand/access: no matching versions for query "latest"

去.mod:

module bitbucket.org/nxtlab/sticktothebrand

go 1.12

require (
# Other none bitbucket related packages
)

./app/main.go:

package main

import (
    "bitbucket.org/nxtlab/sticktothebrand"
)

func init() {
    sticktothebrand.Run()
}

树-L 2:

├── Makefile
├── app
│   ├── acl.json
│   ├── app.dev.yaml
│   ├── app.prod.yaml
│   ├── app.test.yaml
│   ├── blocks
│   ├── index.yaml
│   ├── main.go
│   ├── manager -> ../manager/dist/
│   └── static
├── docker
│   ├── Dockerfile
│   ├── go.sh
│   └── run.sh
├── go.mod
├── go.sum
├── gopath
│   └── src
├── manager
│   ├── bower.json
│   ├── config.beta.json
│   ├── config.dev.json
│   ├── config.test.json
│   ├── dist
│   ├── e2e
│   ├── gulp
│   ├── gulpfile.js
│   ├── karma.conf.js
│   ├── package.json
│   ├── protractor.conf.js
│   └── src
├── project
│   └── vval2016
└── research
    ├── Screen Shot 2015-09-10 at 11.29.14.png
    ├── Screen Shot 2015-09-10 at 11.30.29.png
    ├── Screen Shot 2015-09-10 at 11.30.55.png
    ├── Screen Shot 2015-09-10 at 11.31.29.png
    ├── Screen Shot 2015-09-10 at 11.31.34.png
    └── Screen Shot 2015-09-10 at 11.32.40.png

标签: gogoogle-app-enginego-modules

解决方案


包中的某些源文件包含类似import "bitbucket.org/nxtlab/sticktothebrand/access".

您的tree输出表明没有./access子目录,因此主模块中不存在该包。该go命令试图在另一个模块中找到它,但鉴于您的模块路径,我怀疑不存在其他可行的模块。

要修复go mod tidy,您需要找到并删除错误的import语句。


推荐阅读