#!/bin/sh
# script/fmt: format all files (writes) with the goimports that
# script/bootstrap installs. It puts Go's bin directory first on PATH, as
# script/bootstrap does, so it runs that goimports even when the directory
# is not on the caller's PATH.
set -eu

ROOT="$(cd "$(dirname "$0")/.." && pwd -P)"

main() {
    cd "$ROOT"
    gobin="$(go env GOBIN)"
    PATH="${gobin:-$(go env GOPATH)/bin}:$PATH"
    goimports -l -w .
}

main "$@"
