Golang Tutorial

This tutorial describes how to install and configure go, a development utility for the Go programming language.

  1. If you haven't done so already, run through the Tutorial Prerequisites Tutorial.

  2. Either install go from DPorts or from source via a specific release or version control. A tutorial of how to install go from source via version control will be added at a later time.

  3. Apply the change from the previous step to the running shell. Either log out and log back in or run the following command.

    rehash

  4. Create a GOPATH directory where Go programs will be compiled by default. Run the following command.

    mkdir -p $HOME/gopaths/default

  5. Configure the tcsh shell so that whenever it starts it sets the default GOPATH environment variable and adds its binary directory to the path. Skim through $HOME/.cshrc to find the following line.

    set path = (/sbin /bin /usr/sbin /usr/bin /usr/games /usr/local/sbin /usr/local/bin /usr/pkg/sbin /usr/pkg/bin $HOME/bin)

    Then edit the previous line to match the following lines and save the change to disk.

    setenv GOPATH $HOME/gopaths/default
    set path = (/sbin /bin /usr/sbin /usr/bin /usr/games /usr/local/sbin /usr/local/bin /usr/pkg/sbin /usr/pkg/bin $HOME/bin $GOPATH/bin)

  6. Apply the change from the previous step to the running shell. Either log out and log back in or run the following command.

    source $HOME/.cshrc
Unless otherwise stated, the content of this page is licensed under Creative Commons Attribution-ShareAlike 3.0 License