PQ test
This commit is contained in:
2
go.mod
2
go.mod
@@ -1,3 +1,5 @@
|
|||||||
module github.com/gopatchy/shortlinks
|
module github.com/gopatchy/shortlinks
|
||||||
|
|
||||||
go 1.22
|
go 1.22
|
||||||
|
|
||||||
|
require github.com/lib/pq v1.10.9
|
||||||
|
|||||||
15
main.go
15
main.go
@@ -1,16 +1,29 @@
|
|||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"database/sql"
|
||||||
"fmt"
|
"fmt"
|
||||||
"log"
|
"log"
|
||||||
"net/http"
|
"net/http"
|
||||||
"os"
|
"os"
|
||||||
|
|
||||||
|
_ "github.com/lib/pq"
|
||||||
)
|
)
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
port := os.Getenv("PORT")
|
port := os.Getenv("PORT")
|
||||||
if 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)
|
bind := fmt.Sprintf(":%s", port)
|
||||||
|
|||||||
Reference in New Issue
Block a user