This repository was archived by the owner on Aug 1, 2023. It is now read-only.
File tree Expand file tree Collapse file tree 2 files changed +10
-9
lines changed Expand file tree Collapse file tree 2 files changed +10
-9
lines changed Original file line number Diff line number Diff line change @@ -61,13 +61,13 @@ type BatchCreateOpts []CreateOpts
61
61
62
62
// ToDBCreateMap renders a JSON map for creating DBs.
63
63
func (opts BatchCreateOpts ) ToDBCreateMap () (map [string ]interface {}, error ) {
64
- var dbs []map [string ]string
65
- for _ , db := range opts {
64
+ dbs := make ( []map [string ]string , len ( opts ))
65
+ for i , db := range opts {
66
66
dbMap , err := db .ToMap ()
67
67
if err != nil {
68
68
return nil , err
69
69
}
70
- dbs = append ( dbs , dbMap )
70
+ dbs [ i ] = dbMap
71
71
}
72
72
return map [string ]interface {}{"databases" : dbs }, nil
73
73
}
Original file line number Diff line number Diff line change @@ -60,10 +60,11 @@ func (opts CreateOpts) ToMap() (map[string]interface{}, error) {
60
60
user ["host" ] = opts .Host
61
61
}
62
62
63
- var dbs []map [string ]string
64
- for _ , db := range opts .Databases {
65
- dbs = append ( dbs , map [string ]string {"name" : db .Name })
63
+ dbs := make ( []map [string ]string , len ( opts . Databases ))
64
+ for i , db := range opts .Databases {
65
+ dbs [ i ] = map [string ]string {"name" : db .Name }
66
66
}
67
+
67
68
if len (dbs ) > 0 {
68
69
user ["databases" ] = dbs
69
70
}
@@ -76,13 +77,13 @@ type BatchCreateOpts []CreateOpts
76
77
77
78
// ToUserCreateMap will generate a JSON map.
78
79
func (opts BatchCreateOpts ) ToUserCreateMap () (map [string ]interface {}, error ) {
79
- var users []map [string ]interface {}
80
- for _ , opt := range opts {
80
+ users := make ( []map [string ]interface {}, len ( opts ))
81
+ for i , opt := range opts {
81
82
user , err := opt .ToMap ()
82
83
if err != nil {
83
84
return nil , err
84
85
}
85
- users = append ( users , user )
86
+ users [ i ] = user
86
87
}
87
88
return map [string ]interface {}{"users" : users }, nil
88
89
}
You can’t perform that action at this time.
0 commit comments