I'm using https://github.com/go-pg/pg for my PostegreSQL database and Go. I'm trying to get the value of a table Settings
that has the column site_name
but for some reason it is giving me the error panic: model=Settings does not have primary keys
package mypackage
import (
"database"
)
type Settings struct {
SiteName string
}
func Get() string {
var name Settings
err := Db.Model(&name).First()
if err != nil {
panic(err)
}
return name.SiteName
}
I don't have the experience to really understand what's going on here or how to fix it. Any solutions? Thanks!
Example (FirstRow): https://godoc.org/github.com/go-pg/pg#DB.Select