Last active
August 29, 2015 14:20
-
-
Save hitsumabushi/e3c0195d22368361a9ee 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 ( | |
"time" | |
"github.com/jinzhu/gorm" | |
_ "github.com/mattn/go-sqlite3" | |
) | |
func main() { | |
// sqlite3 | |
db, _ := gorm.Open("sqlite3", "gorm.db") | |
// Logger | |
db.LogMode(true) | |
db.DB() | |
db.CreateTable(&Sample{}) | |
} | |
type Sample struct { | |
Id uint `sql:"AUTO_INCREMENT"` | |
LastSeen time.Time `sql:"type:datetime;DEFAULT:'0000-00-00 00:00:00'"` // Contain colon as default value | |
} | |
// go run main.go | |
//=> (/root/src/tmp/main.go:17) | |
//=> [2015-04-30 07:38:57] [1.94ms] CREATE TABLE "samples" ("id" integer,"last_seen" datetime DEFAULT DEFAULT , PRIMARY KEY (id)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment