postgresql – creates a general DBBulkInsert from a specific function (refactoring)

I use the create users func to fill in my wrong database, just for testing.

I use the mass import feature of pq (Https://godoc.org/github.com/lib/pq#hdr-Bulk_imports).

func createUsers () {

User: = []models.user {}

for i: = 0; i <10; i ++ {
User = attach (user, models, user {username: "username" + i, age: i})
}

connStr: = "user = postgres password = postgres dbname = dbname sslmode = disable"
DB, err = sql.Open ("postgres", connStr)
checkErr (err)

txn, err: = DB.Begin ()
checkErr (err)

stmt, err: = txn.Prepare (pq.CopyIn ("user", "username", "age"))
checkErr (err)

for _, user: = area user {
_, err = stmt.Exec (user.Username, user.Age)
checkErr (err)
}

_, err = stmt.Exec ()
checkErr (err)

err = stmt.Close ()
checkErr (err)

err = txn.Commit ()
checkErr (err)
}

What I need now is to make it "generic," not just to the user model.

I think I need something like:

DBBulkInsert (user, "user", "username", "age")

with func DBBulkInsert to like:

func DBBulkInsert (lines []Interface {}, table name, table column ... string) {
// DB var of connection function

txn, err: = DB.Begin ()
checkErr (err)

stmt, err: = txn.Prepare (pq.CopyIn (tableName, tableColumns ...))
checkErr (err)

for _, line: = range lines {
_, err = stmt.Exec (line[0], Line[1]) // THAT'S completely wrong! WHAT TO DO HERE?
checkErr (err)
}

_, err = stmt.Exec ()
checkErr (err)

err = stmt.Close ()
checkErr (err)

err = txn.Commit ()
checkErr (err)
}

Maybe I can also remove the parameters User, Username, Age in the DBBulkInsert (user, "user", "username", "age"), but how? Reflection?