Last active
February 14, 2019 04:40
-
-
Save shootacean/d4b8e40012b5ca4362f1312216d47032 to your computer and use it in GitHub Desktop.
Golangでデータベースに接続する
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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