-
Type: Task
-
Resolution: Done
-
Priority: Major - P3
-
None
-
Affects Version/s: 0.3.0
-
Component/s: Connections, Options & Configuration
-
None
-
Environment:OS: Windows 10
Go version: 1.11.5 windows/amd64
I am getting below error while building my Go code:
.\main.go:23:52: "xp/gomongo/vendor/go.mongodb.org/mongo-driver/mongo/options".Client().ApplyURI undefined (type *"xp/gomongo/vendor/go.mongodb.org/mongo-driver/mongo/options".ClientOptions has no field or method ApplyURI
I have installed mongodb driver using dep as mentioned currently on
main.go -->
package main
import (
"context"
"fmt"
"log"
"net/http"
"time"
"github.com/mongodb/mongo-go-driver/bson"
"go.mongodb.org/mongo-driver/mongo"
"go.mongodb.org/mongo-driver/mongo/options"
)
func rootHandler(w http.ResponseWriter, r *http.Request)
{ fmt.Fprintln(w, "Its Started...") }func main()
{ fmt.Println("Welcome!") ctx, _ := context.WithTimeout(context.Background(), 10*time.Second) client, err := mongo.Connect(ctx, options.Client().ApplyURI("mongodb://localhost:27017")) collection := client.Database("xpdb").Collection("users") res, err := collection.InsertOne(ctx, bson.M\{"name": "Abhay", "place": "Sawantwadi"})
http.HandleFunc("/", rootHandler)
log.Fatal(http.ListenAndServe(":8080", nil))
}