Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save gwpl/26846ef3c066b3109a03101cb58349f0 to your computer and use it in GitHub Desktop.
Save gwpl/26846ef3c066b3109a03101cb58349f0 to your computer and use it in GitHub Desktop.
Installing `mods` golang from source on fresh Ubuntu

Notes on Installing mods from source on Ubuntu , and installing golang:

(based on https://www.perplexity.ai/search/how-to-go-install-github-com-c-yEWTammCQBKQnTv2Mkwgsg )

Step 1: installing Golang:

sudo apt update  # eventually may skip this, depending on update preference

sudo apt install golang-go -y

Step 2: Set up Go environment

go install and compile will create binaries that you may want to be available directly from shell without typing full path. For that we need to add directory into $PATH in ~/.bashrc, add after last 'PATH=' you find in file (or just at the end of file) another line, however FIND if you have "INTERACTIVE ONLY" line in the middle of .bashrc that splits top for all usecases from "interactive only", it usually has this code [[ $- != *i* ]] && return , then you may want to put it as last PATH= above that line,

alternative tutorials advice ~/.profile (there is also ~/.xprofile on ArchLinux... one day I need to refersh which is which 🙈) to work in all (not only bash) shells, and environments:

export PATH=$PATH:/usr/local/go/bin
export GOPATH=$HOME/go
export PATH=$PATH:$GOPATH/bin

Verify installation

go version

And now installing, compiling like mods , ONE of TWO (as golang at some version changed) should work:

go install github.com/charmbracelet/mods@latest

OR

export GO111MODULE=on
go get github.com/charmbracelet/mods@latest

( NOTE for OLD LTS systems:

You may eventually want to consider using newer golang from longsleep repos:

sudo add-apt-repository ppa:longsleep/golang-backports
sudo apt update
sudo apt install golang-go

other methods:

https://www.perplexity.ai/search/can-i-install-on-ubuntu-lts-wh-9F26gYH6S6q8bU4cjy3X.g )

( and reminder that if you need to add-apt-repository on older LTS you may need to temporarily switch to older python and back to new with : https://gist.github.com/gwpl/0977618927d93bfe7b8fecc7cd2d28e5 )

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment