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 關注
- 85 瀏覽
添加回答
舉報
0/150
提交
取消