Now I have several documents, each of which has a key pathand a value of type \A\, \B\, \A\C\, \A\C\D\, \A\E\, \A\E\F\.
I want to find those that have only 1 segment. This means that the result should be \A\and \B\. I use a regex /^\\[^\\]*\\$/that works fine in the MongoDB terminal. But when I tried to apply it to Go programs, this would not work.
Code Code:
var nodeList []NodeEntry // NodeEntry would match every field of one document
err = c.Find(bson.M{"path": bson.M{"$regex": bson.RegEx{"^\\[^\\]*\\$", ""}}}).All(&nodeList)
fmt.Println(nodeList)
Output:
[]
This is so strange, and then I found out that any Regex with \\will create an empty result.
So is this an mgo error?
(I don't know if this is inappropriate, but I also posted this question on the mgo.users mailing list .)