diff options
author | Gibheer <gibheer+git@zero-knowledge.org> | 2024-09-05 19:38:25 +0200 |
---|---|---|
committer | Gibheer <gibheer+git@zero-knowledge.org> | 2024-09-05 19:38:25 +0200 |
commit | 6ea4d2c82de80efc87708e5e182034b7c6c2019e (patch) | |
tree | 35c0856a929040216c82153ca62d43b27530a887 /cmd/monfront/main.go | |
parent | 6f64eeace1b66639b9380b44e88a8d54850a4306 (diff) |
lib/pq is out of maintenance for some time now, so switch to the newer
more active library. Looks like it finally stabilized after a long time.
Diffstat (limited to 'cmd/monfront/main.go')
-rw-r--r-- | cmd/monfront/main.go | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/cmd/monfront/main.go b/cmd/monfront/main.go index f8d8ee7..8943744 100644 --- a/cmd/monfront/main.go +++ b/cmd/monfront/main.go @@ -18,7 +18,7 @@ import ( "time" "github.com/BurntSushi/toml" - "github.com/lib/pq" + _ "github.com/jackc/pgx/v5/stdlib" "golang.org/x/term" ) @@ -107,7 +107,7 @@ func main() { logger := parseLogger(config) - db, err := sql.Open("postgres", config.DB) + db, err := sql.Open("pgx", config.DB) if err != nil { log.Fatalf("could not open database connection: %s", err) } @@ -278,7 +278,7 @@ func checkAction(con *Context) { case "disable": setClause = "enabled = false, updated = now()" case "delete_check": - if _, err := DB.Exec(`delete from checks where id = any ($1::bigint[])`, pq.Array(checks)); err != nil { + if _, err := DB.Exec(`delete from checks where id = any ($1::bigint[])`, checks); err != nil { con.log.Info("could not delete checks", "checks", checks, "error", err) con.Error = "could not delete checks" returnError(http.StatusInternalServerError, con, con.w) @@ -321,7 +321,7 @@ func checkAction(con *Context) { cn.notifier_id, $2 from checks_notify cn join active_checks ac on cn.check_id = ac.check_id - where cn.check_id = any ($1::bigint[])`, pq.Array(&checks), &hostname); err != nil { + where cn.check_id = any ($1::bigint[])`, &checks, &hostname); err != nil { con.log.Info("could not acknowledge check", "error", err) con.Error = "could not acknowledge check" returnError(http.StatusInternalServerError, con, con.w) @@ -334,7 +334,7 @@ func checkAction(con *Context) { } _, err := DB.Exec( "update active_checks set notice = $2 where check_id = any ($1::bigint[]);", - pq.Array(&checks), + &checks, comment) if err != nil { con.w.WriteHeader(http.StatusInternalServerError) @@ -346,7 +346,7 @@ func checkAction(con *Context) { return case "uncomment": _, err := DB.Exec(`update active_checks set notice = null where check_id = any($1::bigint[]);`, - pq.Array(&checks)) + &checks) if err != nil { con.Error = "could not uncomment checks" returnError(http.StatusInternalServerError, con, con.w) @@ -366,7 +366,7 @@ func checkAction(con *Context) { } sql := "update " + setTable + " set " + setClause + " where " + whereColumn + " = any($1::bigint[])" - whereVals = append([]any{pq.Array(&checks)}, whereVals...) + whereVals = append([]any{&checks}, whereVals...) if len(whereFields) > 0 { for i, column := range whereFields { sql = sql + " and " + column + fmt.Sprintf(" = $%d", i+1) |