Shell script to download and set GO environmental paths to allow multiple versions.

Related tags

DevOps Tools gobrew
Overview

gobrew

gobrew lets you easily switch between multiple versions of go. It is based on rbenv and pyenv.

Installation


The automatic installer


You can install this via the command line with either curl or wget.

via curl

curl -L https://raw.github.com/grobins2/gobrew/master/tools/install.sh | sh

via wget

wget --no-check-certificate https://raw.github.com/grobins2/gobrew/master/tools/install.sh -O - | sh

The manual way


  1. Check out gobrew where you want it installed.

     $ git clone git://github.com/cryptojuice/gobrew.git ~/.gobrew
    
  2. Add the following to your shell config.

     export PATH="$HOME/.gobrew/bin:$PATH"
     eval "$(gobrew init -)"
    

    Note:

    • BASH: Add this to /.bashrc (/.bash_profile for Ubuntu users).

    • ZSH: Add this to ~/.zshenv

  3. Source your shell config file (or reopen shell session).

Commands


: gobrew install

Install a specified version of Go.

    $ gobrew install 1.5
: gobrew uninstall
    $ gobrew uninstall 1.5
: gobrew use

Sets which version of Go to use globally.

    $ gobrew use 1.5
: gobrew workspace

Note: 'gobrew workspace' echos the currently set workspace ($GOPATH). Use 'gobrew workspace set' to set your $GOPATH to the current working directory. Use 'gobrew workspace unset' to remove this setting.

    $ cd /path/to/workspace
    $ gobrew workspace set
    $ gobrew workspace unset

Visit http://golang.org/doc/code.html#Workspaces for more on workspaces.

Useful

Updates

To upgrade run update script from .gobrew source with: $ cd ~ $ ./.gobrew/tools/upgrade.sh

Uninstalling

If you want to uninstall it, just run

    $ cd ~
    $ ./.gobrew/tools/uninstall.sh

from the command line and it’ll remove itself.

Comments
  • Change go 1.5 download path & local gobrew version file name  (version -> gobrew_version )

    Change go 1.5 download path & local gobrew version file name (version -> gobrew_version )

    go1.5 download path

    #23

    local gobrew version file name (version -> gobrew_version)

    Sometimes, if I used the version file name in my project, it caused some confusion about gobrew. Version is too normal of a file name, so I changed the file name to gobrew_version.

    opened by anarcher 3
  • gobrew-install doesn't work for go 1.2 on mac os x

    gobrew-install doesn't work for go 1.2 on mac os x

    The go downloads now include the Mac OS X version in the filename, they didn't before so the gobrew-install script needs to be fixed.

    The new file name looks like: go1.2.darwin-amd64-osx10.8.tar.gz instead of go1.2.darwin-amd64.tar.gz

    opened by mindscratch 3
  • Install golang 1.5 not work

    Install golang 1.5 not work

    $ gobrew install 1.5
    + version=1.5
    + version_dir=/Users/abtris/.gobrew/versions/1.5
    ++ pwd
    + OLDPWD=/Users/abtris/go/src/github.com/apiaryio/heroku-datadog-drain-golang
    + mkdir -p /Users/abtris/.gobrew/versions/1.5
    + cd /Users/abtris/.gobrew/versions/1.5
    ++ uname -s
    ++ tr '[:upper:]' '[:lower:]'
    + platform=darwin
    ++ uname -m
    + '[' x86_64 = x86_64 ']'
    + arch=amd64
    + '[' -z 1.5 ']'
    + files_url=https://storage.googleapis.com/golang/
    ++ echo 1.5
    ++ cut -d . -f 1
    + version_major=1
    ++ echo 1.5
    ++ cut -d . -f 2
    + version_minor=5
    + '[' darwin = darwin -a 5 -gt 1 ']'
    ++ uname -r
    ++ cut -d . -f 1
    + darwin_major=14
    + '[' 14 -lt 11 ']'
    + file_name=go1.5.darwin-amd64-osx10.8.tar.gz
    + download=https://storage.googleapis.com/golang/go1.5.darwin-amd64-osx10.8.tar.gz
    + set +e
    + type wget
    + echo 'Installing go1.5.darwin-amd64-osx10.8.tar.gz'
    Installing go1.5.darwin-amd64-osx10.8.tar.gz
    + wget -P /Users/abtris/.gobrew/cache https://storage.googleapis.com/golang/go1.5.darwin-amd64-osx10.8.tar.gz
    --2015-08-20 07:48:52--  https://storage.googleapis.com/golang/go1.5.darwin-amd64-osx10.8.tar.gz
    Resolving storage.googleapis.com... 216.58.209.176, 2a00:1450:400d:806::2010
    Connecting to storage.googleapis.com|216.58.209.176|:443... connected.
    HTTP request sent, awaiting response... 404 Not Found
    2015-08-20 07:48:53 ERROR 404: Not Found.
    
    + tar -zxf /Users/abtris/.gobrew/cache/go1.5.darwin-amd64-osx10.8.tar.gz --strip-components 1
    tar: Error opening archive: Failed to open '/Users/abtris/.gobrew/cache/go1.5.darwin-amd64-osx10.8.tar.gz'
    + rm /Users/abtris/.gobrew/cache/go1.5.darwin-amd64-osx10.8.tar.gz
    rm: /Users/abtris/.gobrew/cache/go1.5.darwin-amd64-osx10.8.tar.gz: No such file or directory
    + cd /Users/abtris/go/src/github.com/apiaryio/heroku-datadog-drain-golang
    + rm -rf /Users/abtris/.gobrew/versions/1.5
    + echo 'gobrew: unable to install 1.5 from binary, download not available'
    gobrew: unable to install 1.5 from binary, download not available
    + exit 1
    

    I think name not contains osx10.8 now.

    opened by abtris 2
  • Command: `gobrew use` not change go version on my Mac

    Command: `gobrew use` not change go version on my Mac

    gobrew install 1.4

    return ok;

    gobrew use 1.4

    return ok;

    gobrew version

    return 1.4

    BUT

    go version

    return 1.6, not ok, because i want it to be 1.4

    did i miss something here?

    opened by ChopperLee2011 1
  • Fix gobrew list debug flag

    Fix gobrew list debug flag

    Fixed spacing in gobrew-list

    Before fix output:

    ➜  gobrew git:(feature/fix-gobrew-list-output) gobrew list
    ++ uname -s
    ++ tr '[:upper:]' '[:lower:]'
    + platform=darwin
    ++ uname -m
    + '[' x86_64 = x86_64 ']'
    + arch=amd64
    + echo 'finding Go versions for darwin-amd64'
    finding Go versions for darwin-amd64
    + url=http://golang.org/dl/
    + go_downloads_list=http://golang.org/dl/
    + curl -s http://golang.org/dl/
    + grep -o '<a href=".*//.*/golang/go.*\.tar\.gz'
    + sed -e 's/<a .*href=['\''"]//' -e 's/["'\''].*$//' -e '/^$/ d'
    + sed -n 's/.*golang\/\(go.*\.tar\.gz\)/\1/p'
    + sed -n 's/go\(.*\)\.darwin-amd64.*/\1/p'
    + uniq
    + sort
    1.2.2
    1.3
    1.3.1
    1.3.2
    1.3.3
    1.3rc1
    1.3rc2
    1.4
    1.4.1
    1.4.2
    1.4beta1
    1.4rc1
    1.4rc2
    

    After:

    ➜  gobrew git:(feature/fix-gobrew-list-output) ./libexec/gobrew-list
    finding Go versions for darwin-amd64
    1.2.2
    1.3
    1.3.1
    1.3.2
    1.3.3
    1.3rc1
    1.3rc2
    1.4
    1.4.1
    1.4.2
    1.4beta1
    1.4rc1
    1.4rc2
    

    With flag:

    ➜  gobrew git:(feature/fix-gobrew-list-output) GOBREW_DEBUG=true ./libexec/gobrew-list
    ++ uname -s
    ++ tr '[:upper:]' '[:lower:]'
    + platform=darwin
    ++ uname -m
    + '[' x86_64 = x86_64 ']'
    + arch=amd64
    + echo 'finding Go versions for darwin-amd64'
    finding Go versions for darwin-amd64
    + url=http://golang.org/dl/
    + go_downloads_list=http://golang.org/dl/
    + curl -s http://golang.org/dl/
    + grep -o '<a href=".*//.*/golang/go.*\.tar\.gz'
    + sed -e 's/<a .*href=['\''"]//' -e 's/["'\''].*$//' -e '/^$/ d'
    + sed -n 's/.*golang\/\(go.*\.tar\.gz\)/\1/p'
    + sed -n 's/go\(.*\)\.darwin-amd64.*/\1/p'
    + uniq
    + sort
    1.2.2
    1.3
    1.3.1
    1.3.2
    1.3.3
    1.3rc1
    1.3rc2
    1.4
    1.4.1
    1.4.2
    1.4beta1
    1.4rc1
    1.4rc2
    
    opened by carkmorwin 1
  • Install script

    Install script

    Created easy to use install / upgrade / uninstall scripts, mentioned by #5

    Install is now just one command. Like:

    curl -L https://raw.github.com/grobins2/gobrew/master/tools/install.sh | sh

    opened by rastasheep 1
  • Fix broken headings in Markdown files

    Fix broken headings in Markdown files

    GitHub changed the way Markdown headings are parsed, so this change fixes it.

    See bryant1410/readmesfix for more information.

    Tackles bryant1410/readmesfix#1

    opened by bryant1410 0
  • Fix use command

    Fix use command

    ls command output vary from OS to OS. In my case, awk '{print $9}' shows time of last modification. Since the last field always shows directory name, we have to get it by $NF to get dir names of go versions.

    $ ls -l
    total 0
    drwxr-xr-x  20 abc123  Hoge Users  680  3 29 15:23 1.8
    
    opened by hakamata-rui 0
  • Local version file should be file,not directory.

    Local version file should be file,not directory.

    If some directory has  "version" directory, go command in `gobrew` does not works.
    
    $ls
    CONTRIBUTING.md  LICENSE     api        flags.go  join_test.go  manage.go  state
    Dockerfile       README.md   cluster    help.go   logo.png      scheduler  userguide.md
    Godeps           ROADMAP.md  discovery  join.go   main.go       script     version
    $go
    cat: /home/anarch/go/swarm/src/github.com/docker/swarm/version: Is a directory
    gobrew: couldn't find any version specified for use
    
    opened by anarcher 0
  • update list command to be less restrictive when greping for files

    update list command to be less restrictive when greping for files

    by not including "go.googlecode.com" in the grep regex, it'll make it easier for gobrew_fw to host the files while to still enabling gobrew list to work.

    opened by mindscratch 0
  • update install.sh to source profile after install

    update install.sh to source profile after install

    sourcing the profile causes the gobrew-init script to run which sets up directories and other stuff which is required to install go. (ex: $HOME/.gobrew/cache gets created)

    opened by mindscratch 0
  • go brew in OSX M1

    go brew in OSX M1

    I'm just setting up a new OSX machine with the M1 chip. I did my go brew installation with the curl command and installed go 1.17. After that I ran gobrew use 1.17. If I run a go command I get zsh: command not found: go

    Could it be that gobrew is installing amd64 instead of arm64?

    https://www.reddit.com/r/golang/comments/rdzsvn/comment/ho5bge9/?utm_source=share&utm_medium=web2x&context=3

    Screen Shot 2021-12-28 at 12 58 26 PM

    opened by redeemefy 0
  • source command not found during installation.

    source command not found during installation.

    Hello.

    Using your install script, it works wrong to install. In the end of script, there is source command to set new profile. As I know, source command is supported only in bash and zsh. I think the script must be executed with bash. Or it is good way that source command is removed and note developers to manually execute it.

    opened by odg0318 0
  • Cannot change version if user group contains two words

    Cannot change version if user group contains two words

    When I run gobrew use 1.8 it shows that the version is not installed.

    I investigated why and I see this line in libexec/gobrew-use file:

    VERSIONS=ls -l $GOBREW_ROOT/versions | egrep '^d' | awk '{print $9}'

    and the problem is in awk command because if my user group contains two words and space in between (my user in an Active Directory user) then the version name is on 10th position.

    I just fixed it to awk '{print $10}' and it works perfect for me, but maybe you could find some general solution for that case.

    Thanks :)

    opened by dskarataev 0
  • init should add paths at the end of $PATH

    init should add paths at the end of $PATH

    When running gobrew init, the CLI adds a few paths to the PATH environment variable. Unfortunately it adds them in the beginning, not at the end.

    This is bad in terms of performance because every call to a binary will then first search these paths, before looking at regular paths such as /usr/local/bin (and I guess that system binaries are more often called than the ones in the directories added by gobrew).

    Furthermore this leads to the situation where binaries in the directories added by gobrew have higher precedence than anything that was installed before.

    Could this be changed to adding the directories in the end instead of at the beginning?

    opened by goloroden 1
  • gb doesn't work, needs GOROOT set

    gb doesn't work, needs GOROOT set

    Whenever I build a gb project, I have to set GOROOT in order for it to find the compiler.

    Sourcing the output from go env takes care of this. It'd be nice if gobrew did this automatically when switching versions.

    opened by cmars 0
Owner
Nick Robinson
Nick Robinson
GitHub Action: Compose multiple (conditional) checks into a single check based on file paths in a pull request

GitHub Action: Composite Example Usage --- name: All Checks on: pull_request: branches: - main jobs: meta: runs-on: - ubuntu-20.

Blend 17 Nov 9, 2022
Basic Kubernetes operator that have multiple versions in CRD. This operator can be used to experiment and understand Operator/CRD behaviors.

add-operator Basic Kubernetes operator that have multiple versions in CRD. This operator can be used to experiment and understand Operator/CRD behavio

Dinesh Parvathaneni 0 Dec 15, 2021
`runenv` create gcloud run deploy `--set-env-vars=` option and export shell environment from yaml file.

runenv runenv create gcloud run deploy --set-env-vars= option and export shell environment from yaml file. Motivation I want to manage Cloud Run envir

sonatard 0 Feb 10, 2022
GitOops is a tool to help attackers and defenders identify lateral movement and privilege escalation paths in GitHub organizations by abusing CI/CD pipelines and GitHub access controls.

GitOops is a tool to help attackers and defenders identify lateral movement and privilege escalation paths in GitHub organizations by abusing CI/CD pipelines and GitHub access controls.

OVO Technology 599 Nov 22, 2022
Execute multiple shell commands like Docker-Compose

parx parx is a simple tool to run multiple commands in parallel while having the output structured like Docker Compose does that. This is useful when

Tobias B. 8 Aug 15, 2022
ip-masq-agent-v2 aims to solve more specific networking cases, allow for more configuration options, and improve observability compared to the original.

ip-masq-agent-v2 Based on the original ip-masq-agent, v2 aims to solve more specific networking cases, allow for more configuration options, and impro

Microsoft Azure 5 Aug 31, 2022
Dockpin - A tool for pinning Docker image and apt package versions

Dockpin Install dockpin with: go install github.com/Jille/[email protected] Dockpin

Jille Timmermans 18 Oct 21, 2022
Seatsserver - Combined frontend and backend to serve HTML versions of seats

seatsserver Combined frontend and backend to serve HTML versions of github.com/s

Jeff Palm 0 Jan 28, 2022
Add, remove, and manage different versions of web-distributed software binaries. No elevated permissions required!

A cross-platform package manager for the web! Add, remove, and manage different versions of web-distributed software binaries. No elevated permissions

Andrew Lee 36 Nov 21, 2022
S3pd - CLI utility that downloads multiple s3 objects at a time, with multiple range-requests issued per object

S3 Parallel Downloader CLI utility that downloads multiple s3 objects at a time,

Colin Bookman 2 May 13, 2022
Manage Go Versions/Projects/Dependencies

rodent rodent is a shell (bash) application which: Manages multiple versions of Go. Allows you to test/build your projects against multiple Go release

Ali Abbas 33 Sep 27, 2022
Terraform Provider for Latest HashiCorp Product Versions

terraform-provider-hashicorpversions The purpose of this Terraform provider is to get the latest semantic version of any of the suite of HashiCorp too

Justin DeFrank 3 May 16, 2022
A tool that scans archives to check for vulnerable log4j versions

log4j-sniffer log4j-sniffer crawls for all instances of log4j that are earlier t

Palantir Technologies 188 Nov 6, 2022
Output all versions of a local git repo, which could be used as test data for your ML program.

gitwalker Output all versions of a local git repo, which could be used as test data for your ML program. Notice This program is under development. Cur

zhuaiballl 0 Dec 27, 2021
Download your Fitbit weight history and connect to InfluxDB and Grafana

WemonFit Weight monitoring for Fitbit, using InfluxDB and Grafana Generating a new certificate openssl req -new -newkey rsa:2048 -nodes -keyout lo

Eduardo Argollo 1 Oct 22, 2022
A simple download file manager that sorts your files into your desired folders, This was meant to be a small project and nothing big.

GoDFM Simply go to the tags and download the .exe file (or compile it yourself by running go build). Add it to your environment paths by going to sett

null 0 Aug 9, 2022
sget is a keyless safe script retrieval and execution tool

sget ⚠️ Not ready for use yet! sget is a keyless safe script retrieval and execution tool Security Should you discover any security issues, please ref

sigstore 22 Nov 1, 2022
Deploy, manage, and secure applications and resources across multiple clusters using CloudFormation and Shipa

CloudFormation provider Deploy, secure, and manage applications across multiple clusters using CloudFormation and Shipa. Development environment setup

Shipa 1 Feb 12, 2022
🗑️ Cleanup script for macOS

MacCleanup A cleanup script for macOS that cleans up your system. Features By default it performs the following tasks: Empty the Trash on All Mounted

MacCleanup 42 Mar 29, 2022