Convert mysql tables and json objects to go structs
Usage:
1.Copy table structure or json to clipboard
2.go setting commond , use any2gostruct to convert ,example: command+shift+p
3.get go struct
table:
CREATE TABLE order
(
id
bigint unsigned NOT NULL AUTO_INCREMENT,
sn
varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT 'sn',
PRIMARY KEY (id
)
) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
convert:
type Order struct {
Id uint64 json:"id" db:"id"
Sn string json:"sn" db:"sn"
}
json:
{
"id": "cgt-2025**-",
"model": "doubao-seedance-1-0-pro-250528",
"status": "succeeded",
"content": {
"video_url": "xxx"
},
"seed": 10,
"resolution": "720p",
"duration": 5,
"ratio": "16:9",
"framespersecond": 24,
"usage": {
"completion_tokens": 108900,
"total_tokens": 108900
},
"created_at": 1743414619,
"updated_at": 1743414673
}
convert:
type jStruct struct {
Id string json:"id"
Model string json:"model"
Status string json:"status"
Content interface{} json:"content"
Seed int json:"seed"
Resolution string json:"resolution"
Duration int json:"duration"
Ratio string json:"ratio"
Framespersecond int json:"framespersecond"
Usage interface{} json:"usage"
CreatedAt int json:"created_at"
UpdatedAt int json:"updated_at"
}