ostafen / clover

A lightweight document-oriented NoSQL database written in pure Golang.
MIT License
633 stars 54 forks source link

Small v2 package annoyance #112

Open geoah opened 1 year ago

geoah commented 1 year ago

Hey there, I'm playing around with clover which looks really nice, so thank you for open sourcing it! :) This is just a very small annoyance when trying to use this library for which I don't think a PR can help.


tl;dr: I think that go is getting confused with the v2 branch name being the main branch?


trying to go get clover's v2 package tried to get the latest "alpha" tag instead of the v2 git branch. the error seems to be because I'm trying to use the document package that didn't exist when the tag was created.

go get -u github.com/ostafen/clover/v2/document
go: module github.com/ostafen/clover/v2@upgrade found (v2.0.0-alpha.2), but does not contain package github.com/ostafen/clover/v2/document

same with latest, kinda expected this.

go get -u github.com/ostafen/clover/v2/document@latest
go: module github.com/ostafen/clover/v2@latest found (v2.0.0-alpha.2), but does not contain package github.com/ostafen/clover/v2/document

trying to explicitely get the v2 branch fails, this one is the weird one for me.

go get -u github.com/ostafen/clover/v2/document@v2
go: github.com/ostafen/clover/v2/document@v2: no matching versions for query "v2"

to get the latest version for v2 I need to actually use the latest commit sha.

go get -u github.com/ostafen/clover/v2/document@dce004e1cd8e1add291511b96bb3977036abcddb
go: added github.com/ostafen/clover/v2 v2.0.0-alpha.2.0.20221120132158-dce004e1cd8e

other branch names also work as expected.

go get -u github.com/ostafen/clover/v2/document@v2-store-merge
go: added github.com/ostafen/clover/v2 v2.0.0-alpha.2.0.20230203105032-c302b23db778

ps. It's getting a bit late here so I hope I'm not just missing something completely obvious here and wasting your time, I do apologise in advance though if that's the case :D

ostafen commented 1 year ago

I could try to delete the tag and create it again

geoah commented 1 year ago

Hey, not sure that will solve anything. Were you able to replicate this by any chance? Might just be something on my setup.

ostafen commented 1 year ago

go get github.com/ostafen/clover/v2 correctly fetches the last tagged version (which is v2.0.0-alpha.2) on my machine. That version has not the document package, so what you are getting is correct.

geoah commented 1 year ago

That is correct, but usually you should be able to get the latest version by doing go get github.com/ostafen/clover/v2@main to pull from a specific branch. That works fine for branches like v2-store-merge but doesn't work for the v2 branch for some reason, I assume it might have something to do with the way go mod makes assumptions about versions.

geoah commented 1 year ago

Awh found it. Basically you can't pull from a branch that looks like a version.

https://github.com/golang/go/commit/21f548400650e4e7047202ee1894ee6ddd44de82

Note that branches with names that overlap with other module query syntax cannot be selected explicitly. For example, the suffix @v2 means the latest version starting with v2, not the branch named v2.

joyhope commented 1 year ago

The version problem is really annoying. Git using v2.0.0-alpha.2, but it is not the latest repository.

The document said the default engine is bblot, but the fact is not, The default engine is /badger/v3. In the v2, I could not found how to switch to the bbolt engine.

The project is good, but the version and doc seems stop the new user.

joyhope commented 1 year ago

I could not find the way to use the latest repository code. Is there any suggestion?

ostafen commented 1 year ago

@joyhope: just pushed a new tag, which should fix your issue. Let me know if that works

joyhope commented 1 year ago

thank you very much. I just found a model replace could solve the problem, but it is a ugly solution. ( I had to manual copy your repository.

After you update, it seems perfect to use the normal method. It works. Thanks !!!

Shane-XB-Qian commented 1 year ago

@ostafen so here v2 just meant a 'dev' version (or actually a branch and/but it is 'default' branch)? the new coming commits all would merged to v2 only, right? // would you switch to use 'main' as default branch later?