@@ -3,6 +3,12 @@ package mongodb
3
3
import (
4
4
"context"
5
5
"fmt"
6
+ "io"
7
+ "net/url"
8
+ "os"
9
+ "strconv"
10
+ "time"
11
+
6
12
"github.com/cenkalti/backoff/v4"
7
13
"github.com/golang-migrate/migrate/v4/database"
8
14
"github.com/hashicorp/go-multierror"
@@ -11,12 +17,6 @@ import (
11
17
"go.mongodb.org/mongo-driver/mongo/options"
12
18
"go.mongodb.org/mongo-driver/x/mongo/driver/connstring"
13
19
"go.uber.org/atomic"
14
- "io"
15
- "io/ioutil"
16
- "net/url"
17
- os "os"
18
- "strconv"
19
- "time"
20
20
)
21
21
22
22
func init () {
@@ -114,7 +114,7 @@ func WithInstance(instance *mongo.Client, config *Config) (database.Driver, erro
114
114
}
115
115
116
116
func (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
118
118
uri , err := connstring .Parse (dsn )
119
119
if err != nil {
120
120
return nil , err
@@ -182,7 +182,7 @@ func (m *Mongo) Open(dsn string) (database.Driver, error) {
182
182
return mc , nil
183
183
}
184
184
185
- //Parse the url param, convert it to boolean
185
+ // Parse the url param, convert it to boolean
186
186
// returns error if param invalid. returns defaultValue if param not present
187
187
func parseBoolean (urlParam string , defaultValue bool ) (bool , error ) {
188
188
@@ -199,7 +199,7 @@ func parseBoolean(urlParam string, defaultValue bool) (bool, error) {
199
199
return defaultValue , nil
200
200
}
201
201
202
- //Parse the url param, convert it to int
202
+ // Parse the url param, convert it to int
203
203
// returns error if param invalid. returns defaultValue if param not present
204
204
func parseInt (urlParam string , defaultValue int ) (int , error ) {
205
205
@@ -241,7 +241,7 @@ func (m *Mongo) Version() (version int, dirty bool, err error) {
241
241
}
242
242
243
243
func (m * Mongo ) Run (migration io.Reader ) error {
244
- migr , err := ioutil .ReadAll (migration )
244
+ migr , err := io .ReadAll (migration )
245
245
if err != nil {
246
246
return err
247
247
}
@@ -268,8 +268,8 @@ func (m *Mongo) executeCommandsWithTransaction(ctx context.Context, cmds []bson.
268
268
return & database.Error {OrigErr : err , Err : "failed to start transaction" }
269
269
}
270
270
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
273
273
return err
274
274
}
275
275
if err := sessionContext .CommitTransaction (sessionContext ); err != nil {
0 commit comments