rewrite in go/bash