How to install Golang on chrome os - go

I tried the method from https://go.dev/doc/install and I keep getting "-bash: go: command not found".
I tried https://gist.github.com/conoro/4fca191fad018b6e47922a21fab499ca but I dont know what command to run when I get to the "Use sftp or scp on the ARM64 device to get the tar.gz file" stage. Any help???

You don't need to compile from source in Developer mode, you can just use the Chromebrew-provided version.
If your Chromebook is relatively new, you can enable the Linux VM now built into ChromeOS to install Go without developer mode. Follow the steps from the following Google Support article to enable this feature- https://support.google.com/chromebook/answer/9145439. This has been tested on a Samsung Chromebook Plus on version 71.0.3578.127. If this feature is not available for you, you will need to enable Developer Mode.
This tutorial will show you how to install, build, and run Go on Chrome OS.
Please note this has only been tested on a 64GB LTE Pixel, however it should work on other Chromebooks. Note that enabling developer mode reduces the security guarantees offered by Chrome OS.
Install Go
First download the latest version of Go for Linux from the Go Downloads page.
After that, open a shell by hitting (CTRL+ALT+T) and typing in shell then hit enter. Then extract it using the following command (when replacing < Go Linux package > with the name of the file you downloaded):
sudo tar xpvf ~/Downloads/< Go Linux package > -C /usr/local
Go should now be installed you can test this by typing /usr/local/go/bin/go. If it installed correctly, you should see the Go help prompt. Go is now installed.
Create a Workspace
To keep this simple just create a folder called /usr/local/go/work. Also, create a folder called src inside /usr/local/go/work/.
Set PATH
Add the following to ~/.bashrc:
export GOPATH="/usr/local/go/work"
export PATH="${PATH}:/usr/local/go/bin:${GOPATH}/bin"
This will allow you to run your Go programs in your shell.
Test if it worked
First create a folder inside of your /usr/local/go/src folder. After that create a file in your folder called hello.go with the following in it:
package main
import "fmt"
func main() {
fmt.Println("Hello, Chrome OS!")
}
Now, run go install hello. Then, run ${GOPATH}/bin/hello (or just hello if you setup your GOPATH above) and you should see Hello, Chrome OS!.
Collected from : https://github.com/golang/go/wiki/ChromeOS

If you want to download Go on a Chromebook in Dev Mode, without installing Linux follow these steps:
Enable Dev mode, in case you have not already.
Download the latest version of Go for Linux (https://go.dev/dl/)
IN YOUR TERMINAL
Type Shell
mkdir ~/Coding
tar -xzf ~/Downloads/ADD YOUR VERSION HERE -C ~/Coding/
echo "sudo mount -i -o remount,exec /home/chronos/user/" >> ~/.bash_profile
echo "sudo mount -i -o remount,exec /tmp/" >> ~/.bash_profile
SET ENV VARIABLES
export GOROOT=~/CS/go *Where you extracted Go*
export GOPATH=~/Downloads/go *Where you wanna keep your Go projects*
PATH=$PATH:$GOROOT/bin:$GOPATH/bin *This adds everything to PATH*
To make sure everything works restart your Terminal and type go version you should see the version you installed

Related

Why /user/local/go isn't recognized as a Go SDK in GoLand

I'm trying to setup GoLand to use WSL 2 as in this guide: https://www.jetbrains.com/help/go/how-to-use-wsl-development-environment-in-product.html
I've installed Go in the Ubuntu distro following the linux instructions on the GoLang website, and go version prints outs the version I downloaded, so it appears that Go is working inside WSL.
So now I tried to create a new project in GoLand, and I'm getting errors, which appear to come from the fact that the SDK isn't loaded in GoLand. The guide doesn't offer much guidance on this, so I just tried to add a local SDK.
When I select /usr/local/go I get an error that it's not a valid SDK.
So I created the ~/go directory, and then updated my .zshrc file to export the GOPATH and GOROOT environment variables, even though they already showed up when I ran go env, doing this got them to show up on a simple env call.
But I'm still getting the invalid SDK error like above.
Is there a configuration step I'm missing that isn't spelled out in the guide? I came across this old post about creating symlinks to fake the expected directory structure. I haven't done this because it's a really old post, has comments that say this has been fixed, and seems like a really odd solution.
Support for Go SDK in WSL2 will be available in the next 2021.3 release, please see GO-10618.
October 2021 update.
2021.3 reaches Early Access Program at the moment. GoLand suggests selecting Go SDK on WSL2 mount if the location of the project is on WSL2 as well.
I experienced this on my Debian machine and I wasn't using WSL2. I found that the actual cause of the issue is that Goland is unable to read the directory /usr/local/go/bin due to inadequate permission.
A possible solution is to run the goland.sh script as root. The script can be found in the bin/goland.sh directory of the Goland IDE folder. Here is a simple command to do run Goland as the root
export HISTIGNORE='*sudo -S*' && echo "sudo-password-here" | sudo -S /absolute-path-to-goland.sh
export HISTIGNORE='*sudo -S*' tells bash history to ignore caching any command matching sudo -S* to bash history. This way, your sudo-password isn't saved into the bash-history file.
echo "sudo-password-here" | pipes your sudo password as input to the next command.
sudo -S tells bash to read input for password prompt from stdin, which has been provided through the echo command.
Alternatively, you can just install the latest version of Goland. Hopefully, it doesn't come with this bug

Tried to install golang command but it shows command is not found

I have set my $GOPATH=$HOME/go and $GOROOT=usr/local/go
I tried to follow this tutorial so that I could do hot reload on my golang webserver
https://github.com/codegangsta/gin
I installed it via
go get github.com/codegangsta/gin
then I tried to run
gin -h
It shows command is not found
I have checked that the library is installed in my $GOPATH/bin
What should I do?
you need to add these commands to your shell startup (.bashrc or similar) or do them manually before using gin
export GOPATH=$HOME/go
export PATH=$GOPATH/bin:$PATH

How to create a desktop-entry for anaconda on Ubuntu 17.10?

I've recently installed anaconda3 in Ubuntu 17.10 (system environment). To run anaconda-navigator, I've to activate root for each time as
Source ~/anaconda3/bin/activate root
And to run it I've to write each time
anaconda-navigator
Now I am wanted to create a desktop entry but I'm having errors at multiple stages. Can you please explain from beginning how to create a desktop-entry for anaconda3 on Linux?
EDIT: I've tried using this post on AskUbuntu. But, it failed for me. It is not showing on dock-bar as well as in /usr/share/applications. I'm really frustrated.
First, check if anaconda3 is installed on your system or not (Sometime the package may be broken due to network issues during installation (Not worked for me)). And whether you are able to launch anaconda-navigator without a desktop entry.
For creating a desktop entry
Step 1. Open your text editor and save the following content as Anaconda.desktop to your home directory.
[Desktop Entry]
Version=1.0
Type=Application
Name=Anaconda-Navigator
GenericName=Anaconda
Comment=Scientific Python Development Environment - Python3
Exec='$HOME/anaconda3/bin/anaconda-navigator'
Categories=Development;Science;IDE;Qt;Education;
Icon=$HOME/anaconda3/lib/python3.8/site-packages/anaconda_navigator/static/images/anaconda-icon-256x256.png
Terminal=false
StartupNotify=true
MimeType=text/x-python;
Take care with the Python version. in $HOME/anaconda3/lib/python3.8/site-packages/anaconda_navigator/static/images/anaconda-icon-256x256.png change python3.8 if needed
Step 2. Copy your Anaconda.desktop to /usr/share/applications/ as root (Because you might need permission to copy at /usr/share/applications/)
sudo cp Anaconda.desktop /usr/share/applications
This will create a desktop entry named Anaconda in /usr/share/applications/.
Step 3. add this line export PATH="$HOME/anaconda3/bin:$PATH" to your /etc/profile or $HOME/.bashrc
Step 4. Check if Anaconda is added to your application dock. If you didn't find it, search it in search-bar. Or you can run directly from /usr/share/applications/Anaconda.desktop.

Mac app Packages - Running pre-installation script issues

So I'm using the packages app : http://s.sudre.free.fr/Software/Packages/about.html
Running a pre-installation script for my package that does something simple such as
#!/bin/sh
cd ~/Desktop
mkdir test_folder
exit 0
Gives me no issues, creates the folder and installation is successful. (It is a dummy app/package and I am only testing to make sure I can get the installation script to work).
However, when I try to test the actual content I want to install for the user, it says the installation is successful but nothing happens.
#!/bin/sh
export GOPATH=~/gocode
export PATH=$PATH:$GOPATH/bin
go get -d github.com/lightningnetwork/lnd
cd $GOPATH/src/github.com/lightningnetwork/lnd
make && make install
exit 0
I'm not sure if my script is incorrect? Do I have to use only native bash commands because I am aware that go & get aren't traditional bash commands. I'm really confused because this script works 100% fine when running normally & as admin through the terminal yet gives me issues when using the Packages App.
I'm totally open to achieving this installation a different way (not using Packages or having to do a different script approach).
An alternative I was thinking was to create an Electron Menu Bar app that would run the same script, but I'm not sure if this would work either.
Thank you so much for your help!

FreeSurfer installed on Ubuntu

I am trying to install FreeSurfer on Ubutun. I follow an installation instruction online. When I walk through this step, I have a question:
Here is your FreeSurfer license. Place the four lines between theCUT HERE markers in a file named "license.txt" in the directory pointed toby the $FREESURFER_HOME environment variable (see the FreeSurfer documentation).
#---------------CUT HERE---------------
xxxxxx
xxxxx
xxxxx
xxxxx
#---------------CUT HERE---------------
Does that mean I have to paste the four lines into a file called "license.txt"? I actually did in this way. I paste the four lines at the end of a file called "license.txt". But when I finish all the steps and check the installation. There is an error popping up:
ERROR: FreeSurfer license file /home/urser/Downloads/freesurfer/license.txt not found.
But the license.txt is really in that fold called "freesurfer". Do I misunderstand the instruction?
Please follow the instructions:
Requirements
sudo apt-get install tcsh
Download and installation
cd ~
# this is the 64 bit version
wget ftp://surfer.nmr.mgh.harvard.edu/pub/dist/freesurfer/5.3.0/freesurfer-Linux-centos6_x86_64-stable-pub-v5.3.0.tar.gz
cd /usr/local/
sudo tar -xzvf ~/freesurfer-*.tar.gz
Setting the environment
echo "FREESURFER_HOME=/usr/local/freesurfer" >> ~/.bashrc
echo 'source $FREESURFER_HOME/SetUpFreeSurfer.sh' >> ~/.bashrc
Cleaning up -> this is optional
rm ~/freesurfer-*.tar.gz
Registering your software
Now register at https://surfer.nmr.mgh.harvard.edu/registration.html and paste the license code emailed to you here, PLEASE BE EXTRA CAREFUL WITH THIS STEP:
sudo gedit /usr/local/freesurfer/license.txt
I am not sure whether this next step is essential, but I usually run it.
sudo ln -s /usr/lib/libtiff.so.{4,3}
Conclusions
All in all, installing Freesurfer is not that hard, but installing it in a new linux system is surely a better option than messing with VirtualMachines in Windows. The VM that they offer in their website does not allow to run the commands in files residing in the host machine, which is the point of running a VM in the end.
Source
The current freesurfer 7.2 version has some semblance of a binary installer (.deb package) that worked for me on Ubuntu 18
(https://surfer.nmr.mgh.harvard.edu/fswiki/rel7downloads). On Windows, in lieu of running Ubuntu in a VirtualBox VM (which includes an X-server), you can use the windows subsystem for linux (WSL) to download and run the default Ubuntu image. Then try to download and run the freesurfer .deb binary installer in Ubuntu. With WSL 1 or 2 you can access the path to your windows home directory mounted in linux (https://surfer.nmr.mgh.harvard.edu/fswiki//FS7_wsl). You still need to setup an X server on Windows 10 to work with freeview running in Ubuntu under WSL, but I read that should no longer be necessary with WSL in Windows 11. Once you obtain a freesurfer license (https://surfer.nmr.mgh.harvard.edu/registration.html) then just set the environment variable FS_LICENSE to the absolute path for the license file, e.g., in your shell init file in Ubuntu (in order for freeview to run).

Resources