Tutorial On Go Compiler Has Some Issues

November 19, 2018 1.5k views
Go Configuration Management Debian

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.

https://www.digitalocean.com/community/tutorials/how-to-install-go-1-6-on-ubuntu-16-04

mc@mc-VirtualBox:~/work/src/github.com/user/hello$ 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/github.com/user/hello$ ls
hello.go
mc@mc-VirtualBox:~/work/src/github.com/user/hello$ cd ..
mc@mc-VirtualBox:~/work/src/github.com/user$ cd hello
mc@mc-VirtualBox:~/work/src/github.com/user/hello$ ls
hello.go
mc@mc-VirtualBox:~/work/src/github.com/user/hello$ cd ..
mc@mc-VirtualBox:~/work/src/github.com/user$ sudo rm -r
rm: missing operand
Try ‘rm –help’ for more information.
mc@mc-VirtualBox:~/work/src/github.com/user$ cd ..
mc@mc-VirtualBox:~/work/src/github.com$ cd ..
mc@mc-VirtualBox:~/work/src$ sudo rm -r github.com
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
hello.go
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
/home/mc/work/bin/hello
mc@mc-VirtualBox:~/work/src/hello$ cd ..
mc@mc-VirtualBox:~/work/src$ ls

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 https://storage.googleapis.com/golang/go1.6.linux-amd64.tar.gz
    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/github.com/user/hello
    9  nano ~/work/src/github.com/user/hello/hello.go
   10  go install github.com/user/hello
   11  hello

Jarland

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.

Have another answer? Share your knowledge.