Created
June 21, 2016 04:07
-
-
Save narenaryan/29037098b2a4f07865f0cf384261f305 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 ( | |
| "bytes" | |
| "database/sql" | |
| "fmt" | |
| "net/http" | |
| "github.com/gin-gonic/gin" | |
| _ "github.com/go-sql-driver/mysql" | |
| ) | |
| func main() { | |
| db, err := sql.Open("mysql", "root:passapp@tcp(127.0.0.1:3306)/gotest") | |
| if err != nil { | |
| fmt.Print(err.Error()) | |
| } | |
| defer db.Close() | |
| // make sure connection is available | |
| err = db.Ping() | |
| if err != nil { | |
| fmt.Print(err.Error()) | |
| } | |
| type Person struct { | |
| Id int | |
| First_Name string | |
| Last_Name string | |
| } | |
| router := gin.Default() | |
| // Add API handlers here | |
| router.Run(":3000") | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment