This commit is contained in:
Ian Gulliver
2024-11-24 22:05:22 -06:00
parent f23dc46b02
commit c291f59708
2 changed files with 16 additions and 1 deletions

2
go.mod
View File

@@ -1,3 +1,5 @@
module github.com/gopatchy/shortlinks
go 1.22
require github.com/lib/pq v1.10.9

15
main.go
View File

@@ -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)