package main import ( "database/sql" _ "encoding/json" "fmt" "net/http" _ "github.com/lib/pq" ) func main() { http.HandleFunc("/data", get) err := http.ListenAndServe(":8080", nil) if err != nil { panic(err) } } func get(w http.ResponseWriter, r *http.Request) { w.WriteHeader(http.StatusBadGateway) w.Write([]byte("Hell world!")) } func sql_test() { psqlInfo := fmt.Sprintf("host=%s port=%d user=%s password=%s dbname=%s sslmode=disable", "localhost", 5432, "postgres", "", "inventory") db, err := sql.Open("postgres", psqlInfo) if err != nil { panic(err) } defer db.Close() rows, err := db.Query("") if err != nil { panic(err) } defer rows.Close() }