Skip to content

Instantly share code, notes, and snippets.

@narenaryan
Created June 21, 2016 04:07
Show Gist options
  • Select an option

  • Save narenaryan/29037098b2a4f07865f0cf384261f305 to your computer and use it in GitHub Desktop.

Select an option

Save narenaryan/29037098b2a4f07865f0cf384261f305 to your computer and use it in GitHub Desktop.
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