Go modules 如何将go模块指向尚未推送到Git的本地模块

Go modules 如何将go模块指向尚未推送到Git的本地模块,go-modules,Go Modules,我有什么: 专用存储库 存储库中的子模块 go.mod包含 module github.com/username/privaterepo go 1.16 require github.com/username/privaterepo/submodule latest replace ( github.com/username/privaterepo/submodule latest => target ./submodule ) module github.com/user

我有什么

  • 专用存储库
  • 存储库中的子模块
  • go.mod
    包含

    module github.com/username/privaterepo
    
    go 1.16
    
    require github.com/username/privaterepo/submodule latest
    
    replace (
        github.com/username/privaterepo/submodule latest => target ./submodule
    )
    
    module github.com/username/privaterepo/submodule
    
    go 1.16
    
    子模块/go.mod
    包含

    module github.com/username/privaterepo
    
    go 1.16
    
    require github.com/username/privaterepo/submodule latest
    
    replace (
        github.com/username/privaterepo/submodule latest => target ./submodule
    )
    
    module github.com/username/privaterepo/submodule
    
    go 1.16
    
    我还没有将任何内容推送到存储库。我正在尝试
    在我的应用程序根目录中进行mod tidy

    $ env GIT_TERMINAL_PROMPT=1 go mod tidy
    Username for 'https://github.com': username
    Password for 'https://username@github.com': 
    go: errors parsing go.mod:
    <...>/go.mod:5: no matching versions for query "latest"
    <...>/go.mod:8:2: no matching versions for query "latest"
    
    $env GIT\u终端\u提示符=1 go mod tidy
    '的用户名https://github.com':用户名
    '的密码https://username@github.com':
    go:解析go.mod时出错:
    /go.mod:5:查询“最新”没有匹配的版本
    /go.mod:8:2:查询“最新”时没有匹配的版本
    

    对于尚未推送到存储库的本地子模块,应该使用哪个版本?甚至可以在没有被推送到存储库的情况下使用这样的本地子模块吗(我认为当看到
    replace
    时,
    go.mod
    甚至不会转到远程源代码)?

    I修复了
    go.mod

    module github.com/username/privaterepo
    
    go 1.16
    
    require github.com/username/privaterepo/submodule v0.0.0 //version changed to v0.0.0-00010101000000-000000000000 after go mod tidy
    
    replace github.com/username/privaterepo/submodule => ./submodule