#!/bin/bash

set -eu

bindir="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"

if [ "$#" -eq 0 ]; then
  echo "Usage: bin/go-run path/to/main [args]" >&2
  exit 1
fi

ldflags="-X github.com/runconduit/conduit/pkg/version.Version=$($bindir/root-tag)"
go build -v -i -race -o .gorun -ldflags "$ldflags" "./$1"
shift
exec ./.gorun "$@"
