2

What do I have:

  1. private repository
  2. sub-module in the repository
submodule/
 submodule.go
 go.mod
 go.sum
main.go
go.mod
go.sum

go.mod contains

module github.com/username/privaterepo

go 1.16

require github.com/username/privaterepo/submodule latest

replace (
    github.com/username/privaterepo/submodule latest => target ./submodule
)

submodule/go.mod contains

module github.com/username/privaterepo/submodule

go 1.16

I didn't push anything to the repository yet. I'm trying to go mod tidy in the root of my app:

$ env GIT_TERMINAL_PROMPT=1 go mod tidy
Username for 'https://github.com': username
Password for 'https://[email protected]': 
go: errors parsing go.mod:
<...>/go.mod:5: no matching versions for query "latest"
<...>/go.mod:8:2: no matching versions for query "latest"

Which version should I use for my local submodule which is not pushed to the repository yet? Is it even possible to use such local submodule when it's not pushed to the repository (I thought that go mod wouldn't even go to remote source when it sees replace)?

1 Answer 1

4

I fixed go.mod with

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
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.