#!/bin/sh
# script/fmt: format all files (writes).
set -eu

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

main() {
    cd "$ROOT"
    # script/bootstrap installs goimports into Go's bin directory, which
    # need not be on PATH.
    gobin="$(go env GOBIN)"
    [ -n "$gobin" ] || gobin="$(go env GOPATH)/bin"
    PATH="$gobin:$PATH"
    gofmt -s -w .
    goimports -w .
}

main "$@"
