Last active
January 31, 2025 15:04
-
-
Save AlekSi/c2f20c5f6dfa86115be5453b746f47a4 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module gist.github.com/AlekSi/c2f20c5f6dfa86115be5453b746f47a4 | |
go 1.23 | |
toolchain go1.23.5 | |
require go.mongodb.org/mongo-driver/v2 v2.0.0 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= | |
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= | |
github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI= | |
github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= | |
go.mongodb.org/mongo-driver/v2 v2.0.0 h1:Jfd7XpdZa9yk3eY774bO7SWVb30noLSirL9nKTpavhI= | |
go.mongodb.org/mongo-driver/v2 v2.0.0/go.mod h1:nSjmNq4JUstE8IRZKTktLgMHM4F1fccL6HGX1yh+8RA= |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"log" | |
"go.mongodb.org/mongo-driver/v2/bson" | |
) | |
func main() { | |
log.SetFlags(0) | |
v := bson.D{ | |
{ | |
Key: "string", | |
Value: "\"", | |
}, | |
{ | |
Key: "regex", | |
Value: bson.Regex{Pattern: "", Options: "\""}, | |
}, | |
} | |
b, err := bson.MarshalExtJSON(v, true, true) | |
if err != nil { | |
log.Fatal(err) | |
} | |
log.Printf("Marshalled\n\n%#v\n\nas\n\n%s", v, b) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment