When the Go client attempts to connect to mongodb, the following error message is displayed:

error parsing uri: unescaped @ sign in user info 
Copy the code

Mongo-go-driver checks for special characters when parsing connection strings because password contains @ special characters:

func (p *parser) parse(original string) error { ... // fetch the hosts field hosts := uri if idx := strings.IndexAny(uri, "/? @ "); idx ! = -1 { if uri[idx] == '@' { return fmt.Errorf("unescaped @ sign in user info") } if uri[idx] == '? ' { return fmt.Errorf("must have a / before the query ?" ) } hosts = uri[:idx] } ...Copy the code

Replacing @ with %40, the urlencode for @, solves this problem.