Install & Compatibility
Where this runs
No compatibility data collected yet for this library.
Code
Verified usage
Verified import paths — ran on the pinned version, not inferred.
Connects to PostgreSQL and executes a simple query.
package main
import (
"fmt"
"github.com/go-pg/pg/v10"
)
func main() {
db := pg.Connect(&pg.Options{
Addr: "localhost:5432",
User: "user",
Password: "password",
Database: "mydb",
})
defer db.Close()
var n int
_, err := db.QueryOne(pg.Scan(&n), "SELECT 1")
if err != nil {
fmt.Println(err)
return
}
fmt.Println(n)
}
Debug
Known issues
breakingVersion 8 is incompatible with Go modules; use v10 or later.fixUse github.com/go-pg/pg/v10 instead.
affects: 8.0.7+incompatible
Upgrade
Version history
8.0.7+incompatiblelatest on pkg.go.dev
Audit
Dependencies
No dependency data recorded yet.