bson.M是map [string]接口,而不是slice。并且您需要[] interface为“ $ slice”。
o1 := bson.M{"$project": bson.M{"user": bson.M{"$slice": []interface{}{"$user", 2, 1}}}}如果您共享一些虚拟数据,输入和输出,我可以为您提供进一步的帮助。

bson.M是map [string]接口,而不是slice。并且您需要[] interface为“ $ slice”。
o1 := bson.M{"$project": bson.M{"user": bson.M{"$slice": []interface{}{"$user", 2, 1}}}}如果您共享一些虚拟数据,输入和输出,我可以为您提供进一步的帮助。