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
}
this is my current code, is not my application, and return this error :
app\infrastructure\web\webserver.go:41:23: syntax error: unexpected (, expecting
semicolon or newline or }
the line 41 is the line TaskForIP, i can't remove make because is necesary in application, how i can fix ?
Replace
TaskForIP make(map[string]int)
To
TaskForIP map[string]int
Try something like this:
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)
}