ref: Make the slice at once A small optimization, it will create the slice at once so it won't to expand multiple time later when append is called.
diff --git a/worker/worker.go b/worker/worker.go index f56716f0b7426fcba4407da26eb8150f8dbd1986..06fac3601335e04a918fb55124be04b218578df3 100644 --- a/worker/worker.go +++ b/worker/worker.go @@ -91,10 +91,12 @@ go w.startScheduler(model) } func (w *Worker) GetJobs() []Job { - jobs := []Job{} + jobs := make([]Job, len(w.jobs)) + count := 0 for k, v := range w.jobs { - jobs = append(jobs, Job{Id: k, Status: v}) + jobs[count] = Job{Id: k, Status: v} + count++ } return jobs