package main
import (
"encoding/json"
"fmt"
"github.com/jinzhu/gorm"
_ "github.com/jinzhu/gorm/dialects/postgres"
"github.com/pkg/errors"
)
// 商品
type Product struct {
Id int `gorm:"primary_key"`
Name string `gorm:"not null"`
UserId int `gorm:"not null"`
Spec string `gorm:"not null"` //{"Spec":["dongTech","product"]}
MutiSpec *Spec
}
type Spec struct {
Spec []string //多个标签
}
func GetDB() *gorm.DB {
db, err := gorm.Open("postgres", "postgres://postgres:root@localhost:5432/test?sslmode=disable")
if err != nil {
fmt.Println("db error:", err)
} else {