Formating using Gofmt with local tab=4*stops

This commit is contained in:
smavros 2019-04-05 00:22:08 +02:00
parent 608e772c9b
commit ae0f729a55
2 changed files with 79 additions and 79 deletions

View file

@ -26,27 +26,27 @@ func StartDB() {
db.AutoMigrate(&Simulator{}) db.AutoMigrate(&Simulator{})
db.AutoMigrate(&Signal{}) db.AutoMigrate(&Signal{})
db.AutoMigrate(&SimulationModel{}) db.AutoMigrate(&SimulationModel{})
//db.AutoMigrate(&File{}) db.AutoMigrate(&File{})
db.AutoMigrate(&Project{}) db.AutoMigrate(&Project{})
db.AutoMigrate(&Simulation{}) db.AutoMigrate(&Simulation{})
//db.AutoMigrate(&User{}) db.AutoMigrate(&User{})
db.AutoMigrate(&Visualization{}) db.AutoMigrate(&Visualization{})
db.AutoMigrate(&Signal{}) db.AutoMigrate(&Signal{})
db.AutoMigrate(&Widget{}) db.AutoMigrate(&Widget{})
// Create // Create
db.Create(&Simulator{UUID: "12"}) db.Create(&Simulator{UUID: "12"})
db.Create(&Signal{Name:"Some", Unit:"314"}) db.Create(&Signal{Name: "Some", Unit: "314"})
fooSimMod := SimulationModel{Name:"buz", fooSimMod := SimulationModel{Name: "buz",
InputMapping: []Signal { InputMapping: []Signal{
{Name:"foo", Unit:"42"}, {Name: "foo", Unit: "42"},
{Name:"buz", Unit:"511"}, {Name: "buz", Unit: "511"},
}, },
} }
db.Create(&fooSimMod) db.Create(&fooSimMod)
// get number of associations from SimulationModel table InputMapping column // get number of associations from SimulationModel table InputMapping column
fmt.Println( "Number of associations of InputMapping: ", fmt.Println("Number of associations of InputMapping: ",
db.Model(&fooSimMod).Association("InputMapping").Count()) db.Model(&fooSimMod).Association("InputMapping").Count())
// get the associations from SimulationModel table InputMapping column // get the associations from SimulationModel table InputMapping column

View file

@ -8,106 +8,106 @@ import (
type Simulator struct { type Simulator struct {
gorm.Model gorm.Model
UUID string `gorm:"unique;not null"` UUID string `gorm:"unique;not null"`
Host string `gorm:"default:''"` Host string `gorm:"default:''"`
Modeltype string `gorm:"default:''"` Modeltype string `gorm:"default:''"`
Uptime int `gorm:"default:0"` Uptime int `gorm:"default:0"`
State string `gorm:"default:''"` State string `gorm:"default:''"`
StateUpdateAt time.Time StateUpdateAt time.Time
Properties postgres.Jsonb // TODO: default value? Properties postgres.Jsonb // TODO: default value?
RawProperties postgres.Jsonb // TODO: default value? RawProperties postgres.Jsonb // TODO: default value?
} }
type File struct { type File struct {
gorm.Model gorm.Model
Name string `gorm:"not null"` Name string `gorm:"not null"`
Path string `gorm:"not null"` Path string `gorm:"not null"`
Type string `gorm:"not null"` Type string `gorm:"not null"`
Size uint `gorm:"not null"` Size uint `gorm:"not null"`
ImageHeight uint //only required in case file is an image ImageHeight uint // only required in case file is an image
ImageWidth uint //only required in case file is an image ImageWidth uint // only required in case file is an image
User User `gorm:"not null"` User User `gorm:"not null"`
UserID uint `gorm:"not null"` UserID uint `gorm:"not null"`
Date time.Time Date time.Time
} }
type Project struct { type Project struct {
gorm.Model gorm.Model
Name string `gorm:"not null"` Name string `gorm:"not null"`
User User `gorm:"not null"` User User `gorm:"not null"`
UserID uint `gorm:"not null"` UserID uint `gorm:"not null"`
Visualizations []Visualization Simulation Simulation `gorm:"not null"`
Simulation Simulation `gorm:"not null"` SimulationID uint `gorm:"not null"`
SimulationID uint `gorm:"not null"` Visualizations []Visualization
} }
type Simulation struct { type Simulation struct {
gorm.Model gorm.Model
Name string `gorm:"not null"` Name string `gorm:"not null"`
Running bool `gorm:"default:false"` Running bool `gorm:"default:false"`
Models []SimulationModel `gorm:"foreignkey:BelongsToSimulationID"` User User `gorm:"not null"`
Projects []Project UserID uint `gorm:"not null"`
User User `gorm:"not null"` StartParameters postgres.Jsonb // TODO default value
UserID uint `gorm:"not null"` Models []SimulationModel `gorm:"foreignkey:BelongsToSimulationID"`
StartParameters postgres.Jsonb // TODO default value Projects []Project
} }
type SimulationModel struct { type SimulationModel struct {
gorm.Model gorm.Model
Name string `gorm:"not null"` Name string `gorm:"not null"`
OutputLength int `gorm:"default:1"` OutputLength int `gorm:"default:1"`
InputLength int `gorm:"default:1"` InputLength int `gorm:"default:1"`
OutputMapping []Signal //order of signals is important OutputMapping []Signal // order of signals is important
InputMapping []Signal //order of signals is important InputMapping []Signal // order of signals is important
StartParameters postgres.Jsonb // TODO: default value? StartParameters postgres.Jsonb // TODO: default value?
BelongsToSimulation Simulation `gorm:"not null"` BelongsToSimulation Simulation `gorm:"not null"`
BelongsToSimulationID uint `gorm:"not null"` BelongsToSimulationID uint `gorm:"not null"`
BelongsToSimulator Simulator `gorm:"not null"` BelongsToSimulator Simulator `gorm:"not null"`
BelongsToSimulatorID uint `gorm:"not null"` BelongsToSimulatorID uint `gorm:"not null"`
} }
type User struct { type User struct {
gorm.Model gorm.Model
Username string `gorm:"unique;not null"` Username string `gorm:"unique;not null"`
Password string `gorm:"not null"` Password string `gorm:"not null"`
Mail string `gorm:"default:"` Mail string `gorm:"default:''"`
Role string `gorm:"default:'user'"` Role string `gorm:"default:'user'"`
Projects []Project Projects []Project
Simulations []Simulation Simulations []Simulation
Files []File Files []File
} }
type Visualization struct { type Visualization struct {
gorm.Model gorm.Model
Name string `gorm:"not null"` Name string `gorm:"not null"`
Project Project `gorm:"not null"` Project Project `gorm:"not null"`
ProjectID uint `gorm:"not null"` ProjectID uint `gorm:"not null"`
Widgets []Widget Grid int `gorm:"default:15"`
Grid int `gorm:"default:15"` VisualizationUser User `gorm:"not null"`
VisualizationUser User `gorm:"not null"` VisualizationUserID uint `gorm:"not null"`
VisualizationUserID uint `gorm:"not null"` Widgets []Widget
} }
type Signal struct { type Signal struct {
gorm.Model gorm.Model
Name string `gorm:"not null"` Name string `gorm:"not null"`
Unit string `gorm:"not null"` Unit string `gorm:"not null"`
SimulationModelID uint SimulationModelID uint
//IsRecorded bool `gorm:"default:false"` //IsRecorded bool `gorm:"default:false"`
} }
type Widget struct { type Widget struct {
gorm.Model gorm.Model
Name string `gorm:"not null"` Name string `gorm:"not null"`
Type string `gorm:"not null"` Type string `gorm:"not null"`
Width uint `gorm:"not null"` Width uint `gorm:"not null"`
Height uint `gorm:"not null"` Height uint `gorm:"not null"`
MinWidth uint `gorm:"not null"` MinWidth uint `gorm:"not null"`
MinHeight uint `gorm:"not null"` MinHeight uint `gorm:"not null"`
X int `gorm:"not null"` X int `gorm:"not null"`
Y int `gorm:"not null"` Y int `gorm:"not null"`
Z int `gorm:"not null"` Z int `gorm:"not null"`
IsLocked bool `gorm:"default:false"` IsLocked bool `gorm:"default:false"`
CustomProperties postgres.Jsonb //TODO: default value? CustomProperties postgres.Jsonb // TODO: default value?
VisualizationID uint VisualizationID uint
} }