2

i have try driver mongodb for a simple connection like on tutorial from this repos github mongo-go-driver i just write client like this :

import (
    "fmt"
    "github.com/mongodb/mongo-go-driver/mongo"
    "github.com/mongodb/mongo-go-driver/mongo/options"
)

var client *mongo.Client

func main() {
    fmt.Println("Starting the application...")
    client, err := mongo.NewClient(options.Client().ApplyURI("mongodb://localhost:27017"))

    if err != nil {
        fmt.Println(err.Error())
        return
    }

}

but show error :

cannot use "github.com/mongodb/mongo-go-driver/mongo/options".Client().ApplyURI("mongodb://localhost:27017") (type *"github.com/mongodb/mongo-go-driver/mongo/options".ClientOptions) as type *"go.mongodb.org/mongo-driver/mongo/options".ClientOptions in argument to mongo.NewClient

Driver version use V1.0.0

Any sugestions ?

1 Answer 1

6

you should not use github version of mongo driver. It is just fork of repo located here go.mongodb.org/mongo-driver/mongo. So in first place go get go.mongodb.org/mongo-driver/mongo and then your improts you should change

github.com/mongodb/mongo-go-driver/*

to

go.mongodb.org/mongo-driver/*

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.