Skip to content

Instantly share code, notes, and snippets.

@shootacean
Last active February 14, 2019 04:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save shootacean/d4b8e40012b5ca4362f1312216d47032 to your computer and use it in GitHub Desktop.
Save shootacean/d4b8e40012b5ca4362f1312216d47032 to your computer and use it in GitHub Desktop.
Golangでデータベースに接続する
package main
import (
"database/sql"
)
func main() {
// open database
db, err := sql.Open("mysql", "root:root@tcp(127.0.0.1:3306)/my_database")
if err != nil {
panic(err.Error())
}
defer db.Close()
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment