Install from source

Installing from source #

go install #

If you have go version 1.21 or greater installed, go-swagger can be installed by running:

go install github.com/go-swagger/go-swagger/cmd/swagger@latest

Alternative methods #

Using a released source tarball #

GitHub Downloads (all assets, latest release)

dir=$(mktemp -d) 
download_url=$(curl -s https://api.github.com/repos/go-swagger/go-swagger/releases/latest | \
  jq -r '.tarball_url')

curl -o $dir/swagger -L'#' "$download_url"
cd "$dir"
tar xf swagger
cd go-swagger*
go install ./cmd/swagger

git clone #

Install or update from current source master:

dir=$(mktemp -d) 
git clone https://github.com/go-swagger/go-swagger "$dir" 
cd "$dir"
go install ./cmd/swagger

To install a specific version from source an appropriate tag needs to be checked out first (e.g. v0.30.5). Additional -ldflags are just to make swagger version command print the version and commit id instead of dev.

dir=$(mktemp -d)
git clone https://github.com/go-swagger/go-swagger "$dir" 
cd "$dir"
git checkout v0.30.5
go install -ldflags "-X github.com/go-swagger/go-swagger/cmd/swagger/commands.Version=$(git describe --tags) -X github.com/go-swagger/go-swagger/cmd/swagger/commands.Commit=$(git rev-parse HEAD)" ./cmd/swagger

Copyright 2015-2024 the go-swagger maintainers. This documentation is under an Apache 2.0 license.

Site built with HUGO using hugo-book