Sintax error when using db.Insert()
db = pg.Connect(&pg.Options{
User: "postgres",
Password: "pass",
Database: "database",
})
var n int
_, err := db.QueryOne(pg.Scan(&n), "SELECT 1")
if err != nil {
panic(err)
}
err := db.Insert(&Word{
definition: "definition",
})
if err != nil {
panic(err)
}
Table in the database is called words and the definition of the struct Word is
type Word struct {
word string
language string
definition string
examples []string
}
Output:
panic: ERROR #42601 syntax error at or near ")" (addr="[::1]:5432")
You can look at the generated query via https://github.com/go-pg/pg/wiki/FAQ#how-can-i-viewlog-queries-this-library-generates
@vmihailenco thank you! Thanks to that I realized that fields in struct must be capitalized
Most helpful comment
You can look at the generated query via https://github.com/go-pg/pg/wiki/FAQ#how-can-i-viewlog-queries-this-library-generates