type MongoDBConfig struct {
*mgo.DialInfo
}
func ConfigureMongoDB() (*MongoDBConfig, error) {
//Get gopath
GOPATH := os.Getenv("GOPATH")
file, err := os.Open(GOPATH+RESOURCE_PATH)
if err != nil {
return nil, err
}
decoder := json.NewDecoder(file)
mongoConfig := MongoDBConfig{}
er := decoder.Decode(&mongoConfig)
if er != nil {
return nil, er
}
return &mongoConfig, nil
}
func InitMongoDB() (*Session, error){
mongoConfig, err := ConfigureMongoDB()
if err != nil {
return nil, err
}
session, mongoerr := mgo.DialWithInfo(mongoConfig)
}
Getting error in the last line while passing mongoConfig. I created the struct type of MongoDBConfig using DialInfo type.
Cannot use mongoConfig (type * MongoDBConfig) as type *DialInfo