Tutorial On Go Compiler Has Some Issues

Posted November 19, 2018 2.2k views
DebianConfiguration ManagementGo

When following the tutorial on how to use the Go compiler I ran into some problems with the instructions. When I followed the instructions the program could not find the target file for compilation. I followed the instructions by copying the instructions straight off of the website. Listed below is the website address for the tutorial. Further below is the code I used to get the program to work properly. In a nutshell, the tutorial instructed the user to set up the configuration for GO to find the source file. Even though the configuration file was set up exactly like the tutorial instructed, the GO compiler did not find the source file. I had to remove the subdirectory tree and place the source file where the compiler was searching for the file.

mc@mc-VirtualBox:~/work/src/$ go install hello
can’t load package: package hello: cannot find package “hello” in any of:
/usr/local/go/src/hello (from $GOROOT)
/home/mc/work/src/hello (from $GOPATH)
mc@mc-VirtualBox:~/work/src/$ ls
mc@mc-VirtualBox:~/work/src/$ cd ..
mc@mc-VirtualBox:~/work/src/$ cd hello
mc@mc-VirtualBox:~/work/src/$ ls
mc@mc-VirtualBox:~/work/src/$ cd ..
mc@mc-VirtualBox:~/work/src/$ sudo rm -r
rm: missing operand
Try ‘rm –help’ for more information.
mc@mc-VirtualBox:~/work/src/$ cd ..
mc@mc-VirtualBox:~/work/src/$ cd ..
mc@mc-VirtualBox:~/work/src$ sudo rm -r
mc@mc-VirtualBox:~/work/src$ ls
mc@mc-VirtualBox:~/work/src$ sudo mkdir hello
mc@mc-VirtualBox:~/work/src$ cd hello
mc@mc-VirtualBox:~/work/src/hello$ sudo nano hello.go
mc@mc-VirtualBox:~/work/src/hello$ ls
mc@mc-VirtualBox:~/work/src/hello$ go install hello
mc@mc-VirtualBox:~/work/src/hello$ hello
hello, world
mc@mc-VirtualBox:~/work/src/hello$ which hello
mc@mc-VirtualBox:~/work/src/hello$ cd ..
mc@mc-VirtualBox:~/work/src$ ls

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Submit an Answer
2 answers

Hey friend,

I was not able to reproduce any issue with the tutorial on a new Ubuntu 16 server. Here’s a look at my bash history:

    1  curl -O
    2  tar xvf go1.6.linux-amd64.tar.gz
    3  sudo chown -R root:root ./go
    4  sudo mv go /usr/local
    5  sudo nano ~/.profile
    6  source ~/.profile
    7  mkdir $HOME/work
    8  mkdir -p work/src/
    9  nano ~/work/src/
   10  go install
   11  hello


Hi Jarland,

I attempted to go through the tutorial a second time and what I discovered is that earlier in the tutorial, after downloading the GO program, you check the SHA256SUM on your download. Since you go into the Download directory to do this, you have to back out of this directory to complete the remainder of the tutorial. I did not realize this. My second attempt worked perfectly.