Skip to content

Instantly share code, notes, and snippets.

@lamarmarshall
Created November 5, 2017 13:41
Show Gist options
  • Save lamarmarshall/bdd10cc1013300ec2657c6f38e6910d1 to your computer and use it in GitHub Desktop.
Save lamarmarshall/bdd10cc1013300ec2657c6f38e6910d1 to your computer and use it in GitHub Desktop.
gorm orm for go
package main
import (
"github.com/jinzhu/gorm"
_ "github.com/jinzhu/gorm/dialects/sqlite"
)
//Person - defines person table
type Person struct {
gorm.Model
Name string
Age int
}
func main() {
db, err := gorm.Open("sqlite3", "test.db")
if err != nil {
panic("could not connect")
}
defer db.Close()
db.AutoMigrate(&Person{})
db.Create(&Person{Name: "lamar marshall", Age: 34})
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment