Created
November 5, 2017 13:41
-
-
Save lamarmarshall/bdd10cc1013300ec2657c6f38e6910d1 to your computer and use it in GitHub Desktop.
gorm orm for go
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 ( | |
"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