package models import ( "fmt" "github.com/jinzhu/gorm" u "gocommunity.ru/workshop/internal/utils" ) type Service struct { gorm.Model WorkHistoryId int `json:"work_history_id"` Price int32 `json:"price"` Name string `json:"name"` Description string `json:"description"` } func (service *Service) CreateService() map[string]interface{} { GetDB().Create(service) resp := u.Message(true, "success") resp["service"] = service return resp } func GetServices() []*Service { servicesSlice := make([]*Service, 0) err := GetDB().Table("services").Find(&servicesSlice).Error if err != nil { fmt.Println(err) return nil } return servicesSlice }