I wrote a tool for that: https://github.com/adombeck/gotest-rerun-failed
It reads JSON output from go test -json on stdin, identifies failed tests, and reruns them:
go test -json
go test -json ./... | gotest-rerun-failed