Skip to content

Instantly share code, notes, and snippets.

@labulakalia
Created February 8, 2021 10:56
Show Gist options
  • Save labulakalia/e85c85c8fc2781ade85d7d6e6bcf22b9 to your computer and use it in GitHub Desktop.
Save labulakalia/e85c85c8fc2781ade85d7d6e6bcf22b9 to your computer and use it in GitHub Desktop.
package main
import (
"log"
"gorm.io/driver/sqlite"
"gorm.io/gorm"
"gorm.io/gorm/schema"
)
type Product struct {
gorm.Model
Code string
Price int
}
func main() {
db, err := gorm.Open(sqlite.Open("test.db"), &gorm.Config{
NamingStrategy: schema.NamingStrategy{TablePrefix: "test_"},
})
if err != nil {
log.Fatalln(err)
}
db.Use(&OpentracingPlugin{})
// db.Use(&OpentracingPlugin{})
db.AutoMigrate(&Product{})
db.Create(&Product{Code: "D42", Price: 100})
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment