Publish HTML quickly. https://html.house
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

19 lines
363 B

  1. package htmlhouse
  2. import (
  3. "database/sql"
  4. "fmt"
  5. _ "github.com/go-sql-driver/mysql"
  6. )
  7. func (app *app) initDatabase() error {
  8. var err error
  9. app.db, err = sql.Open("mysql", fmt.Sprintf("%s:%s@tcp(%s:3306)/%s?charset=utf8mb4&parseTime=true", app.cfg.DBUser, app.cfg.DBPassword, app.cfg.DBHost, app.cfg.DBName))
  10. if err != nil {
  11. return err
  12. }
  13. return nil
  14. }