In my last article I talked about why you might want to learn GoLang. In this article we dip our toes into how to install all the necessary dependancies so that we can start learning Go.
How to set up your development environment
Install Brew (skip if you already have brew installed).
ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)”
Update & Install Go, Git, SSH connection and more!
brew update && brew install golang && brew install git
Make sure it's installed by running
Log into your repository tool of choice, I’ll be using gitlab, and create a new project. If you don’t have one already, I highly recommend Gitlab! Let’s call it GoLang and initialize it with a README.Md. Did I mention Gitlab?
Connect to your GoLang Project using SSH & Git to gitlab.
The book Practical Cryptography With Go suggests that ED25519 keys are more secure and performant than RSA keys.
- Set up SSH on your account, open terminal and run
sh-keygen -t ed25519 -C "[email protected]” _Feel free to change the email to your own 😉._ >The -C flag, with a quoted comment, such as an email address, is an optional way to label your SSH keys.
You’ll see a response similar to:
Generating public/private ed25519 key pair. Enter file in which to save the key (/home/user/.ssh/id_ed25519):
Paste in from the prompt the path
/Users/home/.ssh/id_ed25519(for example) and then press return.
Enter a passphrase 2 times and press return. You just created secure ED25519 SSH keys for gitlab!
Now we just have to get those keys into gitlab so we can clone the repo.
pbcopy < ~/.ssh/id_ed25519.pub
Navigate to https://gitlab.com & select your avatar in the upper right corner, and click Settings > SSH Keys.
Paste the public key from step 5 above into the Key text box. Make sure your key includes a descriptive name in the Title text box
Click the Add key button.
Clone the repository:
Create a development directory then clone your new gitlab repository into it. You'll use the copied SSH path from above into this command. Run
mkdir ~/Dev/ && cd ~/Dev/ && git clone [email protected]:DrewKarriker/golang.git && cd ~/Dev/golang
It should look something like this:
[email protected] Dev % git clone [email protected]:DrewKarriker/golang.gitCloning into 'golang'...The authenticity of host 'gitlab.com (2606:4700:90:0:f22e:fbec:5bed:a9b9)' can't be established.ECDSA key fingerprint is SHA256:HbW3g8zUjNSksFbqTiUWPWg2Bq1x8xdGUrliXFzSnUw.Are you sure you want to continue connecting (yes/no/[fingerprint])? yesWarning: Permanently added 'gitlab.com,2606:4700:90:0:f22e:fbec:5bed:a9b9' (ECDSA) to the list of known hosts.Enter passphrase for key '/Users/home/.ssh/id_ed25519':
Bear in mind, you may have to enter your passphrase if applicable
- Navigate in your browser to: https://code.visualstudio.com/ and download Visual Studio Code for your operating system and install it.
- Set up VSCode for Go:
- Set up code command to easily open a project directory from terminal into VSCode. While the VSCode window is in focus, open the command pallet by pressing the
pbuttons. You will see a drop down appear at the top with a
- Type in
shelland select the first suggestion.
Close VSCode so the extention can install properly.
Open your newly downloaded project in VSCode using the Command Line. Run:
or if you
cdinto the directory you want to open, you can run
to open all files within it.
Create a new file by typing
At the bottom right of the screen where it says "Plain Text", click there.
Install the Recommended extensions for Go.
Now we are all set up to get started working with Go!
Next we will be working on our first very tiny program written in Go!
See you in the next section!