#!/bin/sh -e
#
# godoc-gomod - runs godoc for a project using go modules instead of $GOPATH
# dependencies: podman

# shellcheck disable=SC2312

module=$(awk 'NR == 1 { print $2 }' go.mod)
podman run --rm --env "GOPATH=/tmp/go" --publish 6060:6060 \
  -v "$(pwd):/tmp/go/src/${module}" \
  golang:latest /bin/bash -c "awk 'END { print \"http://\"\$1\":6060/pkg/${module}\" }' /etc/hosts && godoc -http=:6060"
