60 err := rows.Scan(&id, &worker_name, &task_cache_id)
61 Expect(err).NotTo(HaveOccurred())
62
63 workerTaskCaches[id] = strings.Join([]string{worker_name, strconv.Itoa(task_cache_id)}, ",") 64 }
65
66 Expect(workerTaskCaches[1]).To(Equal("some-worker,1"))
Some string concatenation operations such as strings.Join
called with a single
or a two element slice can be simplified using binary operators.
This also improves performance as it doesn't need to allocate a new slice and iterate through it.
func foo(x, y string) string {
return strings.Join([]string{x, y}, "_")
}
func foo(x, y string) string {
return x + "_" + y
}