github.com/thetreep/go-swagger@v0.0.0-20240223100711-35af64f14f01/docs/install.md (about) 1 # Installing 2 3 **IMPORTANT NOTE**: `go-swagger` is a tool to mainly generate or analyze source code. In order to make it work after successful 4 installation, see [the prerequisites](https://goswagger.io/generate/requirements.html) on your development environment. 5 6 ## Installing from binary distributions 7 8 go-swagger releases are distributed as binaries that are built from signed tags. It is published [as github release](https://github.com/thetreep/go-swagger/tags), 9 rpm, deb and docker image. 10 11 ### Docker image [](https://quay.io/repository/goswagger/swagger) 12 13 First grab the image: 14 15 ``` 16 docker pull quay.io/goswagger/swagger 17 ``` 18 19 or 20 21 ``` 22 docker pull ghcr.io/go-swagger/go-swagger 23 ``` 24 25 #### For Mac And Linux users: 26 27 ```bash 28 alias swagger='docker run --rm -it --user $(id -u):$(id -g) -v $HOME:$HOME -w $PWD quay.io/goswagger/swagger' 29 swagger version 30 ``` 31 32 or 33 34 ```bash 35 alias swagger='docker run --rm -it --user $(id -u):$(id -g) -v $HOME:$HOME -w $PWD ghcr.io/go-swagger/go-swagger' 36 swagger version 37 ``` 38 39 #### For windows users: 40 41 ```cmd 42 docker run --rm -it -v %CD%:/app -w /app quay.io/goswagger/swagger 43 ``` 44 45 or 46 47 ```cmd 48 docker run --rm -it -v %CD%:/app -w /app ghcr.io/go-swagger/go-swagger 49 ``` 50 51 You can put the following in a file called **swagger.bat** and include it in your path environment variable to act as an alias. 52 53 ```batch 54 @echo off 55 echo. 56 docker run --rm -it -v %CD%:/app -w /app quay.io/goswagger/swagger %* 57 ``` 58 59 or 60 61 ```batch 62 @echo off 63 echo. 64 docker run --rm -it -v %CD%:/app -w /app ghcr.io/go-swagger/go-swagger %* 65 ``` 66 67 ### Homebrew/Linuxbrew 68 69 ``` 70 brew tap go-swagger/go-swagger 71 brew install go-swagger 72 ``` 73 74 ## Install to GOPATH using go install 75 76 If you have `go` version `1.16` or greater installed the binary can be installed by running: 77 78 ``` 79 go install github.com/thetreep/go-swagger/cmd/swagger@latest 80 ``` 81 82 ### Static binary 83 84 You can download a binary for your platform from github: 85 <https://github.com/thetreep/go-swagger/releases/latest> 86 87 ``` 88 download_url=$(curl -s https://api.github.com/repos/go-swagger/go-swagger/releases/latest | \ 89 jq -r '.assets[] | select(.name | contains("'"$(uname | tr '[:upper:]' '[:lower:]')"'_amd64")) | .browser_download_url') 90 curl -o /usr/local/bin/swagger -L'#' "$download_url" 91 chmod +x /usr/local/bin/swagger 92 ``` 93 94 ### Debian packages [](https://cloudsmith.io/~go-swagger/repos/go-swagger/packages/detail/deb/swagger/latest/a=amd64;d=debian%252Fany-version;t=binary/) 95 96 This repo will work for any debian, the only file it contains gets copied to `/usr/bin` 97 98 without sudo: 99 100 ```sh 101 apt update 102 apt install -y apt-transport-https gnupg curl debian-keyring debian-archive-keyring 103 curl -1sLf 'https://dl.cloudsmith.io/public/go-swagger/go-swagger/gpg.2F8CB673971B5C9E.key' | gpg --dearmor -o /usr/share/keyrings/go-swagger-go-swagger-archive-keyring.gpg 104 curl -1sLf 'https://dl.cloudsmith.io/public/go-swagger/go-swagger/config.deb.txt?distro=debian&codename=any-version' > /etc/apt/sources.list.d/go-swagger-go-swagger.list 105 apt update 106 apt install swagger 107 ``` 108 109 with sudo: 110 111 ```sh 112 sudo apt update 113 sudo apt install -y apt-transport-https gnupg curl debian-keyring debian-archive-keyring 114 curl -1sLf 'https://dl.cloudsmith.io/public/go-swagger/go-swagger/gpg.2F8CB673971B5C9E.key' | sudo gpg --dearmor -o /usr/share/keyrings/go-swagger-go-swagger-archive-keyring.gpg 115 curl -1sLf 'https://dl.cloudsmith.io/public/go-swagger/go-swagger/config.deb.txt?distro=debian&codename=any-version' | sudo tee /etc/apt/sources.list.d/go-swagger-go-swagger.list 116 sudo apt update 117 sudo apt install swagger 118 ``` 119 120 ### RPM packages [](https://cloudsmith.io/~go-swagger/repos/go-swagger/packages/detail/rpm/swagger/latest/a=x86_64;d=fedora%252Fany-version;t=binary/) 121 122 This repo should work on any distro that wants rpm packages, the only file it contains gets copied to `/usr/bin` 123 124 ```sh 125 dnf install -y yum-utils 126 rpm --import 'https://dl.cloudsmith.io/public/go-swagger/go-swagger/gpg.2F8CB673971B5C9E.key' 127 curl -1sLf 'https://dl.cloudsmith.io/public/go-swagger/go-swagger/config.rpm.txt?distro=fedora&codename=any-version' > /tmp/go-swagger-go-swagger.repo 128 dnf config-manager --add-repo '/tmp/go-swagger-go-swagger.repo' 129 dnf -q makecache -y --disablerepo='*' --enablerepo='go-swagger-go-swagger' --enablerepo='go-swagger-go-swagger-source' 130 dnf install -y swagger 131 ``` 132 133 ### Installing from source 134 135 Install or update from current source master: 136 137 ``` 138 dir=$(mktemp -d) 139 git clone https://github.com/thetreep/go-swagger "$dir" 140 cd "$dir" 141 go install ./cmd/swagger 142 ``` 143 144 To install a specific version from source an appropriate tag needs to be checked out first (e.g. `v0.25.0`). Additional `-ldflags` are just to make `swagger version` command print the version and commit id instead of `dev`. 145 146 ``` 147 dir=$(mktemp -d) 148 git clone https://github.com/thetreep/go-swagger "$dir" 149 cd "$dir" 150 git checkout v0.25.0 151 go install -ldflags "-X github.com/thetreep/go-swagger/cmd/swagger/commands.Version=$(git describe --tags) -X github.com/thetreep/go-swagger/cmd/swagger/commands.Commit=$(git rev-parse HEAD)" ./cmd/swagger 152 ``` 153 154 You are welcome to clone this repo and start contributing: 155 ``` 156 git clone https://github.com/thetreep/go-swagger 157 ``` 158 159 > **NOTE**: go-swagger works on *nix as well as Windows OS