anonymous-dev
anonymous-dev

Reputation: 3489

reading github.com/username/kit/go/database/go/database/go.mod at revision go/database/v1.0.1: unknown revision go/database/v1.0.1

I have a public kit repo which I pushed v1.0.3 on and has the following structure

go
-database
--database.go
--go.mod
--go.sum

And I require it with

require github.com/michael-ottink/kit/go/database v1.0.3

To test how a kit repo would work. But I get the following error when running go mod tidy in my main project

github.com/michael-ottink/kit/go/[email protected]: reading github.com/michael-ottink/kit/go/database/go/database/go.mod at revision go/database/v1.0.2: unknown revision go/database/v1.0.3

I am new at this and I am struggeling to understand what the problem is ? If any more info is needed I'll update the post.

this is my database.go

package database

    import (
        "gorm.io/gorm"
    )
    
    type Database struct {
        *gorm.DB
    }
    
    type Config struct {
        Driver   string
        Host     string
        Username string
        Password string
        Port     string
        Database string
        Timezone string
    }

This error occurs if you try to require it into a entirely new project with only a go.mod , go.sum and main.go.

Upvotes: 3

Views: 415

Answers (1)

The commit on v1.0.3 added an empty module named slice. The repository became multi-modules and a few more rules are implied. The documentation for a multi-modules repository is here.

Unfortunately, the first folder of the repository named /kit does not contain the modules but only its sub-folder /go.

When multiple modules are found, a tag like v1.0.3 is attributed to the repository but there is no modules which means that go get github.com//michael-ottink/[email protected] does not do anything.

When trying to go get the subfolder with go get github.com//michael-ottink/kit/[email protected], the returned error confirms that no module was found.

To go get the repo, tag could look like [email protected]

To tag each module individually, tag could be go/database/v1.0.3. When the slice module is ready, it can be tagged similarly.

It remains that when starting with modules, one repository per module is a safer bet as quoted in the documentation (here):

For all but power users, you probably want to adopt the usual convention that one repo = one module. It's important for long-term evolution of code storage options that a repo can contain multiple modules, but it's almost certainly not something you want to do by default.

Upvotes: 3

Related Questions