package main
import (
"database/sql"
"fmt"
"html/template"
"net/http"
"unicode"
_ "github.com/lib/pq"
"golang.org/x/crypto/bcrypt"
)
/* const (
host = "localhost"
port = 5432
user = "postgres"
password = "*******"
dbname = "db"
) */
var tpl *template.Template
var db *sql.DB
func main() {
tpl, _ = template.ParseGlob("templates/*.html")
var err error
db, err = sql.Open("postgresql", "root:password@tcp(localhost:localhost/db")
if err != nil {
panic(err.Error())
}
defer db.Close()
http.HandleFunc("/register", registerHandler)
http.HandleFunc("/registerauth", registerAuthHandler)
fmt.Println("Listening")
http.ListenAndServe("localhost:8080", nil)
}
当我运行它时,我得到一个错误:
恐慌:sql:未知驱动程序“postgresql”(忘记导入?)
顺便说一句,我只是在网上上课,但他们使用的是 MySQL,而我使用的是 Postgres,我正在为我的论文做这个
qq_遁去的一_1
相关分类