PQ test
This commit is contained in:
2
go.mod
2
go.mod
@@ -1,3 +1,5 @@
|
||||
module github.com/gopatchy/shortlinks
|
||||
|
||||
go 1.22
|
||||
|
||||
require github.com/lib/pq v1.10.9
|
||||
|
||||
15
main.go
15
main.go
@@ -1,16 +1,29 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"database/sql"
|
||||
"fmt"
|
||||
"log"
|
||||
"net/http"
|
||||
"os"
|
||||
|
||||
_ "github.com/lib/pq"
|
||||
)
|
||||
|
||||
func main() {
|
||||
port := os.Getenv("PORT")
|
||||
if port == "" {
|
||||
port = "80"
|
||||
log.Fatalf("please set PORT")
|
||||
}
|
||||
|
||||
pgConn := os.Getenv("PGCONN")
|
||||
if pgConn == "" {
|
||||
log.Fatalf("please set PGCONN")
|
||||
}
|
||||
|
||||
_, err := sql.Open("postgres", pgConn)
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
|
||||
bind := fmt.Sprintf(":%s", port)
|
||||
|
||||
Reference in New Issue
Block a user