douyan2002 2018-08-28 04:34
浏览 1078

go build一直抱怨:go.mod具有post-v0模块路径

Following the release of Go 1.11, I have been trying to move my repositories to Go modules, by adding a go.mod file at their root.

One of my root libraries my.host/root is in its version 17.0.1, so I wrote in its go.mod file:

module my.host/root/v17

I tagged that version v17.0.1 as documented in the Go modules manual.

When I try to make a new Go project that uses my root library, like:

package main

import root "my.host/root/v17"

func main() {
    root.DoSomething()
}

And try to compile it, I get the following error:

go: my.host/root@v0.0.0-20180828034419-6bc78016491a: go.mod has post-v0 module path "my.host/root/v17" at revision 6bc78016491a

I am at loss figuring out why this happens. I explicitly added v17.0.1 in the go.mod file, yet every attempt at go build replaces the entry with a v0.0.0-20180828034419-6bc78016491a version which then fails because at that commit, the go.mod file module entry of my root library indeed ends with a v17, as it should.

For the record, this commit is the same as the tagged v17.0.1 version.

What am I doing wrong here? How can I debug this situation?

  • 写回答

2条回答 默认 最新

  • duangong1979 2018-08-28 12:48
    关注

    I had make two mistakes:

    • My initial v17.0.0 tag would point to a commit where go.mod did not contain the v17 import path suffix. As a result, it seems Go tooling considers the whole v17 major version as a v0/v1 instead, even if later v17 tags point to a commit with a correct go.mod directive, hence the commit ID "translation".
    • In my dependent projects, in the go.mod file, I mistakenly specified require my.host/root v17.0.1 instead of require my.host/root/v17 v17.0.1.

    After fixing both those issues, everything seems back to normal and it works perfectly. I wish the documentation had been clearer about this but I guess this is a good opportunity to make a contribution!

    评论

报告相同问题?

悬赏问题

  • ¥15 Python中的request,如何使用ssr节点,通过代理requests网页。本人在泰国,需要用大陆ip才能玩网页游戏,合法合规。
  • ¥15 Oracle触发器记录修改前后的字段值
  • ¥100 为什么这个恒流源电路不能恒流?
  • ¥15 有偿求跨组件数据流路径图
  • ¥15 写一个方法checkPerson,入参实体类Person,出参布尔值
  • ¥15 我想咨询一下路面纹理三维点云数据处理的一些问题,上传的坐标文件里是怎么对无序点进行编号的,以及xy坐标在处理的时候是进行整体模型分片处理的吗
  • ¥15 CSAPPattacklab
  • ¥15 一直显示正在等待HID—ISP
  • ¥15 Python turtle 画图
  • ¥15 stm32开发clion时遇到的编译问题