github.com/rzurga/go-swagger@v0.28.1-0.20211109195225-5d1f453ffa3a/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/go-swagger/go-swagger/tags),
     9  rpm, deb and docker image.
    10  
    11  ### Docker image [![Docker Repository on Quay](https://quay.io/repository/goswagger/swagger/status "Docker Repository on Quay")](https://quay.io/repository/goswagger/swagger)
    12  
    13  First grab the image:
    14  
    15  ```
    16  docker pull quay.io/goswagger/swagger
    17  ```
    18  
    19  #### For Mac And Linux users:
    20  
    21  ```bash
    22  alias swagger='docker run --rm -it  --user $(id -u):$(id -g) -e GOPATH=$(go env GOPATH):/go -v $HOME:$HOME -w $(pwd) quay.io/goswagger/swagger'
    23  swagger version
    24  ```
    25  
    26  #### For windows users:
    27  
    28  ```cmd
    29  docker run --rm -it --env GOPATH=/go -v %CD%:/go/src -w /go/src quay.io/goswagger/swagger
    30  ```
    31  
    32  You can put the following in a file called **swagger.bat** and include it in your path environment variable to act as an alias.
    33  
    34  ```batch
    35  @echo off
    36  echo.
    37  docker run --rm -it --env GOPATH=/go -v %CD%:/go/src -w /go/src quay.io/goswagger/swagger %*
    38  ```
    39  
    40  ### Homebrew/Linuxbrew
    41  
    42  ```
    43  brew tap go-swagger/go-swagger
    44  brew install go-swagger
    45  ```
    46  
    47  ### Static binary
    48  
    49  You can download a binary for your platform from github:
    50  <https://github.com/go-swagger/go-swagger/releases/latest>
    51  
    52  ```
    53  download_url=$(curl -s https://api.github.com/repos/go-swagger/go-swagger/releases/latest | \
    54    jq -r '.assets[] | select(.name | contains("'"$(uname | tr '[:upper:]' '[:lower:]')"'_amd64")) | .browser_download_url')
    55  curl -o /usr/local/bin/swagger -L'#' "$download_url"
    56  chmod +x /usr/local/bin/swagger
    57  ```
    58  
    59  ### Debian packages [ ![Download](https://api.bintray.com/packages/go-swagger/goswagger-debian/swagger/images/download.svg) ](https://bintray.com/go-swagger/goswagger-debian/swagger/_latestVersion)
    60  
    61  This repo will work for any debian, the only file it contains gets copied to `/usr/bin`
    62  
    63  ```
    64  sudo apt install gnupg ca-certificates
    65  sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 379CE192D401AB61
    66  echo "deb https://dl.bintray.com/go-swagger/goswagger-debian ubuntu main" | sudo tee /etc/apt/sources.list.d/goswagger.list
    67  sudo apt update 
    68  sudo apt install swagger
    69  ```
    70  
    71  ### RPM packages [ ![Download](https://api.bintray.com/packages/go-swagger/goswagger-rpm/swagger/images/download.svg) ](https://bintray.com/go-swagger/goswagger-rpm/swagger/_latestVersion)
    72  
    73  This repo should work on any distro that wants rpm packages, the only file it contains gets copied to `/usr/bin`
    74  
    75  ```
    76  wget https://bintray.com/go-swagger/goswagger-rpm/rpm -O bintray-go-swagger-goswagger-rpm.repo
    77  ```
    78  
    79  
    80  ### Installing from source
    81  
    82  Install or update from current source master:
    83  
    84  ```
    85  dir=$(mktemp -d) 
    86  git clone https://github.com/go-swagger/go-swagger "$dir" 
    87  cd "$dir"
    88  go install ./cmd/swagger
    89  ```
    90  
    91  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`.
    92  
    93  ```
    94  dir=$(mktemp -d)
    95  git clone https://github.com/go-swagger/go-swagger "$dir" 
    96  cd "$dir"
    97  git checkout v0.25.0
    98  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
    99  ```
   100  
   101  You are welcome to clone this repo and start contributing:
   102  ```
   103  git clone https://github.com/go-swagger/go-swagger
   104  ```
   105  
   106  > **NOTE**: go-swagger works on *nix as well as Windows OS