Deviopath › Go

First Error Wins

Hard · Concurrency

Run each job in a goroutine. Jobs return an error string ("" means success). Return the first non-empty error in **input order** (not finish order). If every job succeeds, return "".

Write FirstError(jobs) where jobs[i] == 0 succeeds and any other value is fmt.Sprintf("job %d", value) after a tiny sleep so they overlap. RunFirst(codes) is already written.

Next: Linked List Cycle