Removed goto statements in pkg

This patch replaces all occurences of the goto statement in the
Docker project (except in the `vendor` directory), replacing them
with `for` loops instead.

Closes #6332

Docker-DCO-1.1-Signed-off-by: Aleksa Sarai <cyphar@cyphar.com> (github: cyphar)