type WebServer struct {
TodoService task.TodoService
UserService usr.UserService
SessionService session.Service
CategoryService task.CategoryService
WorkerService task.WorkerService
ApiWorkerService task.ApiWorkerService
BlacklistService task.BlacklistService
LabelService *labels.Service
StatusService *statuses.Service
InviteService *invites.Service
Runner *task.Runner
TaskForIP make(map[string]int)
Params WebServerParams
}
这是我当前的代码,不是我的应用程序,并返回此错误:
app\infrastructure\web\webserver.go:41:23: syntax error: unexpected (, expecting
semicolon or newline or }
第41行是TaskForIP行,由于应用程序中的必要,我无法删除make,我该如何解决?
答案 0 :(得分:1)
替换
TaskForIP make(map[string]int)
收件人
TaskForIP map[string]int
答案 1 :(得分:1)
尝试这样的事情:
package main
import (
"log"
)
type WebServer struct {
TodoService task.TodoService
UserService usr.UserService
SessionService session.Service
CategoryService task.CategoryService
WorkerService task.WorkerService
ApiWorkerService task.ApiWorkerService
BlacklistService task.BlacklistService
LabelService *labels.Service
StatusService *statuses.Service
InviteService *invites.Service
Runner *task.Runner
TaskForIP map[string]int
Params WebServerParams
}
func (ws WebServer) NewInstance() WebServer {
ws.TaskForIP = make(map[string]int)
return ws
}
func main() {
webServer := WebServer{}.NewInstance()
log.Println(webServer)
}