Giter Site home page Giter Site logo

canha / golang-tools-install-script Goto Github PK

View Code? Open in Web Editor NEW
525.0 11.0 138.0 103 KB

Simple Bash script to automate Go language tools single user installation or even removal.

License: Apache License 2.0

Shell 100.00%
shell linux macos bash installer golang fish-shell

golang-tools-install-script's Introduction

golang-tools-install-script

Bash script to automate installation and removal of single-user Go language tools.

Feel free to change the variables on the beginning to match whatever version of Go you need.

Tested working on:

  • โœ… Ubuntu 16.04 to 20.04
  • โœ… macOS Sierra (10.12) to Big Sur (11.3)

Supported shells:

  • Bash, fish, Zsh

๐Ÿ”จ Requirements

  • wget or curl
  • Bash shell

โฉ Install

Download and run with wget or curl. Here's the short version using the official git.io shortening:

# Linux typically has wget installed
wget -q -O - https://git.io/vQhTU | bash

# macOS typically has curl installed
curl -L https://git.io/vQhTU | bash

Or, if you are more comfortable with the raw URL:

wget -q -O - https://raw.githubusercontent.com/canha/golang-tools-install-script/master/goinstall.sh | bash

# or...
curl https://raw.githubusercontent.com/canha/golang-tools-install-script/master/goinstall.sh | bash

๐Ÿ“ฆ Install a custom Go version

Pass the --version option into the script including the version that you wish to install.

Example:
wget -q -O - https://git.io/vQhTU | bash -s -- --version 1.18

# or...
curl -L https://git.io/vQhTU | bash -s -- --version 1.18

๐Ÿšซ Uninstall

Pass the --remove option into the script:

wget -q -O - https://git.io/vQhTU | bash -s -- --remove

# or...
curl -L https://git.io/vQhTU | bash -s -- --remove

๐Ÿ“ Notes

By default, the script will create .go and go folders on your home directory and add the needed variables and PATH expansion.

$HOME/.go is the directory where Go will be installed to.

$HOME/go is the default workspace directory.

Read more about the workspace.

In order to install Go into another location, set the environment variables $GOROOT and $GOPATH before (un)installing:

export GOROOT=/opt/go
export GOPATH=$HOME/projects/go

golang-tools-install-script's People

Contributors

canha avatar carlosas avatar dialex avatar elimisteve avatar hamzaanis avatar iamcalledrob avatar imvexed avatar lfkeitel avatar majorthorn avatar mxrch avatar nepomuceno avatar puckzxz avatar re3turn avatar simp7 avatar unixabg avatar vhaidamaka avatar zelazna avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

golang-tools-install-script's Issues

script doesn't parse mkdir properly

Line 58: mkdir -p "$HOME/go/{src,pkg,bin}"

This actually produces a folder at ~/go/ called "{src,pkg,bin}", not three separate folders.

I suggest changing the line to:

for folder in {src,pkg,bin};do mkdir -p ${folder};done

Syntax error if `profile` file doesn't have trailing newline

Hey thanks for putting this together. Wanted to let you know about a bug that exists when the profile file (e.g. .zshrc doesn't have a trailing newline. This script writes Go path variables to the end like so:

# GoLang
export GOROOT=/Users/user/.go
export PATH=$GOROOT/bin:$PATH
export GOPATH=/Users/user/go
export PATH=$GOPATH/bin:$PATH

Say there's no trailing newline in that file and the last line happens to be something like:

export NODE_OPTIONS="--max-old-space-size=16000"

That results in this script writing:

export NODE_OPTIONS="--max-old-space-size=16000"# GoLang
export GOROOT=/Users/user/.go
export PATH=$GOROOT/bin:$PATH
export GOPATH=/Users/user/go
export PATH=$GOPATH/bin:$PATH

Which will cause a bad option error for any node apps launching from the console. That likely affects other variables at the end as well.

Can't show go version

Hi ,canha
i run your script to setup go in my ubuntu machine . i'm just trying to check go version from konsole
but it showing command not found and how can i run my first program in go please help me regrading this

--remove $GOPATH

When removing the Go, shouldn't the script handle the $GOPATH and remove it automatically which would be $HOME/go because in the current script when we reinstall it asks to delete $GOPATH manually?

Problem when downloading from storage.googleapis.com

I love this script. I've been using it for years. But today (and some other times also) I get a 403 Forbidden error while tring to execute it on my Debian 11 VPS:

`yamn@debian:~/golang-tools-install-script-master$ bash goinstall.sh

Downloading go1.20.6.linux-amd64.tar.gz ...
--2023-11-09 10:45:18-- https://storage.googleapis.com/golang/go1.20.6.linux-amd64.tar.gz
Resolving storage.googleapis.com (storage.googleapis.com)... 2a00:1450:400e:80f::201b, 2a00:1450:400e:811::201b, 2a00:1450:400e:805::201b, ...
Connecting to storage.googleapis.com (storage.googleapis.com)|2a00:1450:400e:80f::201b|:443... connected.
HTTP request sent, awaiting response... 403 Forbidden
2023-11-09 10:45:18 ERROR 403: Forbidden.`

Can you help?

SEC3

consider installing git as dependency for "go get"

$> curl -L https://git.io/vQhTU | bash
$> source /root/.bashr
$> go get -u github.com/cli/cli
go: missing Git command. See https://golang.org/s/gogetcmd
package github.com/cli/cli: exec: "git": executable file not found in $PATH

maybe a message would be enough tho

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.