1: posts
Reading ModeRO
$ cat 20190816_ghginst.md

#Installing and using ghg

Date:2019-08-16 (Fri)
>Using ghg to download stable executables from GitHub Releases and run them from the command line.

I used go get to install tools written in Go, but that could give me the latest source instead of a stable release, or a binary without the project’s build information.
Projects can publish their prebuilt stable binaries on GitHub Releases.
ghg saves me a trip to each project’s releases page to find the binary I want.
Here’s how I installed it.

##In this article

  • Installing ghg
  • Download and run release binaries with ghg

##Installing ghg

You can find ghg in this repository:

To install ghg this way, you’ll need a working Go environment.
If you haven’t set one up yet, start with my Go setup guide.

Run this command to install ghg:

Bash
$ go get github.com/Songmu/ghg/cmd/ghg

With the Go binary directory ($GOPATH/bin) on your PATH, you should be able to check the installation:

Bash
$ ghg version
ghg version: 0.2.0 (rev: Devel)

OK if the version is displayed.

##Using ghg

First, add the directory where ghg stores downloaded binaries to your PATH.
Add this line to ~/.profile or ~/.bashrc:

Bash
export PATH="$(ghg bin):$PATH"

All right, let's give it a try.
Here are three ways to fetch a binary:

Bash
// Example: download a release from https://github.com/motemen/ghq
$ ghg get motemen/ghq

// Upgrade an existing installation
$ ghg get -u motemen/ghq

// Request a specific version
$ ghg get motemen/ghq@v0.12.6

Since the directory is on your PATH, you can run the downloaded program by name:

Bash
$ ghq --version
ghq version 0.12.6 (rev:f75cda1)

##Wrapping up

That gives me a quick way to install prebuilt release binaries.
I’d recommend it if you often install tools from GitHub Releases.

## Comments

"20190816_ghginst.md" [readonly]3L, 1786B
utf-8100%