douxi3404 2019-08-06 16:55
浏览 1204
已采纳

如何使用Go模块在特定分支上导入软件包

I'm reorganizing a repo from the following structure:

repo_root/
   |- foo/
       |- foo.go
   |- bar/
       |- bar.go
   |- go.mod

into the following:

repo_root/
   |- gosrc/
        |- foo/
             |- foo.go
        |- bar/
             |- bar.go
        |- go.mod

Now, inside foo.go of the original repo structure, I do something like below to import the package bar:

import "github.com/arb_name/repo_root/bar"

Now, with the new repo, I changed it to:

import "github.com/arb_name/repo_root/gosrc/bar"

Now, I run into the problem that go build of foo.go failed because

cannot find module providing package github.com/arb_name/repo_root/gosrc/bar

I certainly do not want to change the master branch of repo without first making sure that the restructure of repo works. I'm wondering if there is a way to solve my situation? I can work on my fork but ideally not directly making change to my fork's master.

Thanks!

  • 写回答

1条回答 默认 最新

  • drvvvuyia15070493 2019-08-06 17:14
    关注

    Make sure that you updated your go.mod file to

    module github.com/arb_name/repo_root/gosrc

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

报告相同问题?

悬赏问题

  • ¥15 乌班图ip地址配置及远程SSH
  • ¥15 怎么让点阵屏显示静态爱心,用keiluVision5写出让点阵屏显示静态爱心的代码,越快越好
  • ¥15 PSPICE制作一个加法器
  • ¥15 javaweb项目无法正常跳转
  • ¥15 VMBox虚拟机无法访问
  • ¥15 skd显示找不到头文件
  • ¥15 机器视觉中图片中长度与真实长度的关系
  • ¥15 fastreport table 怎么只让每页的最下面和最顶部有横线
  • ¥15 R语言卸载之后无法重装,显示电脑存在下载某些较大二进制文件行为,怎么办
  • ¥15 java 的protected权限 ,问题在注释里