# Contributor: Kevin Daudt <kdaudt@alpinelinux.org>
# Contributor: Will Sinatra <wpsinatra@gmail.com>
maintainer="leso-kn <info@lesosoftware.com>"
pkgname=go-swag
pkgver=1.16.4
pkgrel=6
pkgdesc="Automatically generate RESTful API documentation with Swagger 2.0 for Go"
url="https://github.com/swaggo/swag"
arch="all"
license="MIT"
makedepends="make go"
subpackages="$pkgname-doc"
source="$pkgname-$pkgver.tar.gz::https://github.com/swaggo/swag/archive/refs/tags/v$pkgver.tar.gz"
options="net"
builddir="$srcdir/swag-$pkgver"

export GOCACHE="${GOCACHE:-"$srcdir/go-cache"}"
export GOTMPDIR="${GOTMPDIR:-"$srcdir"}"
export GOMODCACHE="${GOMODCACHE:-"$srcdir/go"}"

build() {
	make build
}

check() {
	# do not NOT as root! some tests fail if run as root.
	export GOROOT="/usr/lib/go"

	if [ "$CARCH" = "riscv64" ]; then
		# TestGen_BuildDescriptionWithQuotes makes use of 'go build -buildmode=plugin' which is not supported on riscv64.
		go test -run '!(^(TestGen_BuildDescriptionWithQuotes)$)' ./...
	else
		make test
	fi
}

package() {
	install -Dm644 license "$pkgdir"/usr/share/licenses/$pkgname/LICENSE

	install -Dm0755 swag "$pkgdir"/usr/bin/go-swag
	ln -s /usr/bin/go-swag "$pkgdir/usr/bin/swag"
}

sha512sums="
2a0f418ae87da8d32aa0a9dd2bdb3e19bf24d0e2ad46af7eb8fa1bee7fc6f974ee5294bbc49f86a0a0822310d4d4797e10a959e8961fce93c27e32c4cc3d0d2c  go-swag-1.16.4.tar.gz
"
