func GetMgoURL(ip, user, password string, port int) string {urlString := ""if user == "" && password == "" {urlString = fmt.Sprintf("mongodb://%s:%d/admin", ip, port)}else {urlString = fmt.Sprintf("mongodb://%s:%s@%s:%d/admin", url.QueryEscape(user), url.QueryEscape(password), ip, port)}return urlString}url := service.GetMgoURL(reqPara.Ip, reqPara.User, reqPara.Password, reqPara.Port)session, err := mgo.Dial(url)
本页内容是否解决了您的问题?