The thing that got me was the extreme verbosity of sql queries, at least with the standard library solution. Take this example:
var (
id int
name string
)
rows, err := db.Query("select id, name from users where id = ?", 1)
if err != nil {
log.Fatal(err)
}
defer rows.Close()
for rows.Next() {
err := rows.Scan(&id, &name)
if err != nil {
log.Fatal(err)
}
log.Println(id, name)
}
err = rows.Err()
if err != nil {
log.Fatal(err)
}
Imagine how much you need to do if you have 30 columns to account for!
Your statement:
Like, when you'd pass an argument to a function and expect the return to be a modified version, but instead, it was the argument itself that got modified
The thing that got me was the extreme verbosity of sql queries, at least with the standard library solution. Take this example:
Imagine how much you need to do if you have 30 columns to account for!
Your statement:
This is only true for maps, because the value of a map is an address. Example: play.golang.org/p/KpngA5_5Te4
Notice only for maps does the original value change.
Slices behave that way too. The function has to be written to specifically make a copy of maps and slices if you don't want to mutate the original.
Ah yeah fair enough.