Database that I am using is postgresql. What I want to do is :-
- I have an array which stored different string values (e.g. size of 4 [a,b,c,d]
- I have a table column called "secret"
- I want to insert all the values from the array into the table for every single row (e.g. Let us say we have 4 rows in the table, row 1, row 2, row 3 and row 4. Value "a" from the array should be inserted into row 1, while value "b" should be inserted into row 2, same goes to the others. Basically just update all the rows.
Here is my code :-
secret:= make([]string, count) //count = all the row from the column.
for i := range secret {
_ = i
testSecret:= random_string.GenerateString(10) //method for generating random string
secret = append(secret, testSecret)
}
//update query
pgUpdate := `UPDATE table SET secret= $1`
err = db.QueryRow(pgUpdate, secret).Scan()
if err != nil {
log.Fatalf("Unable to execute the UPDATE query. %v", err)
}
Error that I got "type: unsupported type []string, a slice of string"
I am new to golang, not sure what I should look for so if anything else please educate me.