Uploaded image for project: 'Go Driver'
  1. Go Driver
  2. GODRIVER-849

(type *"project/vendor/go.mongodb.org/mongo-driver/mongo/options".ClientOptions has no field or method ApplyURI)

    • Type: Icon: Task Task
    • Resolution: Done
    • Priority: Icon: Major - P3 Major - P3
    • None
    • Affects Version/s: 0.3.0
    • Labels:
      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))
      }

            Assignee:
            isabella.siu@mongodb.com Isabella Siu (Inactive)
            Reporter:
            abhaygawade abhaygawade
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: