Skip to content

Instantly share code, notes, and snippets.

@zboralski
Last active March 10, 2026 19:37
Show Gist options
  • Select an option

  • Save zboralski/a199bbf0244b4ad0c9f688d9d979ba3f to your computer and use it in GitHub Desktop.

Select an option

Save zboralski/a199bbf0244b4ad0c9f688d9d979ba3f to your computer and use it in GitHub Desktop.
Install Go + GoNB on Google Colab
#!/bin/bash
V=1.26.1
if go version 2>/dev/null | grep -q go$V && test -x /root/go/bin/gonb; then
echo "Go $V + GoNB already installed."
exit 0
fi
echo "Installing Go $V..."
rm -rf /content/go && mkdir -p cache
wget -q -O cache/go.tar.gz https://go.dev/dl/go${V}.linux-amd64.tar.gz
tar xzf cache/go.tar.gz
ln -sf /content/go/bin/go /usr/bin/go
go version
echo "Installing tools..."
for p in github.com/janpfeifer/gonb@latest golang.org/x/tools/cmd/goimports@latest golang.org/x/tools/gopls@latest; do
go install $p 2>&1
done
for b in gonb goimports gopls; do
ln -sf /root/go/bin/$b /usr/bin/$b
done
gonb --install --logtostderr 2>&1
echo "Done! Switch runtime to Go (gonb) and re-run this cell."
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment