package mainimport ( "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.Templatevar db *sql.DBfunc 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,我正在为我的论文做这个
- 1 回答
- 0 关注
- 69 浏览
添加回答
举报
0/150
提交
取消