ostafen / clover

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

Chinese document synchronization #53

Closed jinzhongjia closed 2 years ago

jinzhongjia commented 2 years ago

I updated the Chinese documents according to readme, but I found that some descriptions in the English documents did not seem to be correct.

for example : Invalid types leaves the document untouched:

doc := c.NewDocument()
doc.Set("myField", make(chan struct{}))

log.Println(doc.Has("myField")) // will output false

The code above is printed out as true after I run it.

This is the complete code.

package main

import (
    "log"

    c "github.com/ostafen/clover"
)

func main() {
    db, _ := c.Open("clover-db")
    defer db.Close()

    doc := c.NewDocument()
    doc.Set("myField", make(chan struct{}))

    log.Println(doc.Has("myField"))
}

and when i want to insert the document to collection, it panic

panic: interface conversion: interface {} is nil, not string

goroutine 1 [running]:
github.com/ostafen/clover.(*DB).InsertOne(0xc00063ff58?, {0x1492124?, 0xc000258b70?}, 0xc000217f40)
        C:/Users/jin/go/pkg/mod/github.com/ostafen/clover@v1.1.0/db.go:91 +0xa5
main.main()
        D:/project/go/test/main.go:17 +0x185
exit status 2

And with regard to pointers, it completely adopts value copying and cancels automatic references, right?

My English is not good. There may be some mistakes in my understanding.

ostafen commented 2 years ago

Which version of the library are you using? If you downloaded the library using go modules, then you probably got v1.1.0 version, which is not aligned with last changes on data types internal

jinzhongjia commented 2 years ago

Which version of the library are you using? If you downloaded the library using go modules, then you probably got v1.1.0 version, which is not aligned with last changes on data types internal

That's no problem. I do use go modules, and then how do I get the latest version?

ostafen commented 2 years ago

The latest released version is the v1.1.0, which is the one you are getting using GOMODULES. If you have to use clover in a production environment or project, I suggest you to use v1.1.0. For test purposes, if you want to get the last commit, you use the commit hash like so:

go get https://github.com/ostafen/clover@2c2e4aa

or, equivalently, you can disable GOMODULES when executing the get command in order to tell go get to always fetch the last commit from the repo:

GO111MODULE=off go get github.com/ostafen/clover
jinzhongjia commented 2 years ago

ok, thanks

ostafen commented 2 years ago

Why did you close the PR? It was fine

jinzhongjia commented 2 years ago

Why did you close the PR? I am going to re-launch a new pr after installing the latest version test