@@ -3,6 +3,12 @@ package mongodb
33import (
44 "context"
55 "fmt"
6+ "io"
7+ "net/url"
8+ "os"
9+ "strconv"
10+ "time"
11+
612 "github.com/cenkalti/backoff/v4"
713 "github.com/golang-migrate/migrate/v4/database"
814 "github.com/hashicorp/go-multierror"
@@ -11,12 +17,6 @@ import (
1117 "go.mongodb.org/mongo-driver/mongo/options"
1218 "go.mongodb.org/mongo-driver/x/mongo/driver/connstring"
1319 "go.uber.org/atomic"
14- "io"
15- "io/ioutil"
16- "net/url"
17- os "os"
18- "strconv"
19- "time"
2020)
2121
2222func init () {
@@ -114,7 +114,7 @@ func WithInstance(instance *mongo.Client, config *Config) (database.Driver, erro
114114}
115115
116116func (m * Mongo ) Open (dsn string ) (database.Driver , error ) {
117- //connstring is experimental package, but it used for parse connection string in mongo.Connect function
117+ // connstring is experimental package, but it used for parse connection string in mongo.Connect function
118118 uri , err := connstring .Parse (dsn )
119119 if err != nil {
120120 return nil , err
@@ -182,7 +182,7 @@ func (m *Mongo) Open(dsn string) (database.Driver, error) {
182182 return mc , nil
183183}
184184
185- //Parse the url param, convert it to boolean
185+ // Parse the url param, convert it to boolean
186186// returns error if param invalid. returns defaultValue if param not present
187187func parseBoolean (urlParam string , defaultValue bool ) (bool , error ) {
188188
@@ -199,7 +199,7 @@ func parseBoolean(urlParam string, defaultValue bool) (bool, error) {
199199 return defaultValue , nil
200200}
201201
202- //Parse the url param, convert it to int
202+ // Parse the url param, convert it to int
203203// returns error if param invalid. returns defaultValue if param not present
204204func parseInt (urlParam string , defaultValue int ) (int , error ) {
205205
@@ -241,7 +241,7 @@ func (m *Mongo) Version() (version int, dirty bool, err error) {
241241}
242242
243243func (m * Mongo ) Run (migration io.Reader ) error {
244- migr , err := ioutil .ReadAll (migration )
244+ migr , err := io .ReadAll (migration )
245245 if err != nil {
246246 return err
247247 }
@@ -268,8 +268,8 @@ func (m *Mongo) executeCommandsWithTransaction(ctx context.Context, cmds []bson.
268268 return & database.Error {OrigErr : err , Err : "failed to start transaction" }
269269 }
270270 if err := m .executeCommands (sessionContext , cmds ); err != nil {
271- //When command execution is failed, it's aborting transaction
272- //If you tried to call abortTransaction, it`s return error that transaction already aborted
271+ // When command execution is failed, it's aborting transaction
272+ // If you tried to call abortTransaction, it`s return error that transaction already aborted
273273 return err
274274 }
275275 if err := sessionContext .CommitTransaction (sessionContext ); err != nil {
0 commit comments