Files
x/main.go

36 lines
523 B
Go
Raw Normal View History

2024-11-24 21:36:03 -06:00
package main
import (
2024-11-24 22:05:22 -06:00
"database/sql"
2024-11-24 21:36:03 -06:00
"fmt"
"log"
"net/http"
"os"
2024-11-24 22:05:22 -06:00
_ "github.com/lib/pq"
2024-11-24 21:36:03 -06:00
)
func main() {
port := os.Getenv("PORT")
if port == "" {
2024-11-24 22:05:22 -06:00
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)
2024-11-24 21:36:03 -06:00
}
bind := fmt.Sprintf(":%s", port)
log.Printf("listening on %s", bind)
if err := http.ListenAndServe(bind, nil); err != nil {
log.Fatalf("listen: %s", err)
}
}