我正在使用 PostgreSQL 和 golang 编写后端。我在获取工资栏总和时遇到问题。
这是我的代码:
func GetSalarySum(c echo.Context) error {
db, err := gorm.Open("postgres", "host=localhost port=5433 user=postgres dbname=testone password=root sslmode=disable")
checkError(err)
defer db.Close()
type UpdatedAddress struct {
City string `json:"city;"`
State string `json:"state;"`
Pin string `json:"pin;"`
}
type UpdatedContact struct {
ID uint `json:"id;"`
Mobile string `json:"mobile;"`
Email string `json:"email;"`
}
type NewPerson struct {
ID int `gorm:"primary_key:true;"`
Firstname string `json:"firstname;"`
Lastname string `json:"lastname;"`
Gender string `json:"gender;"`
Salary uint `json:salary;`
Age uint `json:"age"`
Address UpdatedAddress `json:"address"`
Contact UpdatedContact `json:"contact"` …Run Code Online (Sandbox Code Playgroud)