Hi @yi_liu,
Per the Server Discovery and Monitoring specification, an uninitialized member of a replica set is represented via the RSGhost server type. Such servers are not considered selectable for operations, so attempting to execute a command will fail with a server selection error.
To work around this issue in the Go Driver, you can specify that you would like to create a direct connection to the node by either appending directConnection=true to the URI or setting the Direct option in ClientOptions:
uri := "mongodb://user:password@host/?directConnection=true"
client, err := mongo.Connect(ctx, options.Client().ApplyURI(uri))
// OR
uri := "mongodb://user:password@host"
opts := options.Client().ApplyURI(uri).SetDirect(true)
client, err := mongo.Connect(ctx, opts)
Note that this will connect only to that specific node, so if there are other members in the replica set, they will not be targetted for operations.
– Divjot