6.3 KiB
Contents
Installing Ubuntu 16.04
Installing GO
Installing and Setting Up Git
Get a Copy of This Project
Install and Setup Visual Studio Code
Getting Pixel Library
System Dev Files
Installing Ubuntu 16.04
Instead of writing all the steps required for installing Ubuntu 16.04, please refer to the link below:
https://tutorials.ubuntu.com/tutorial/tutorial-install-ubuntu-desktop#0
Installing GO
Ubuntu 16.04 has an old version of GO so we need to update it.
To do this we make use of the official PPA provided by the GOLang project:
sudo add-apt-repository ppa:longsleep/golang-backports
sudo apt update
sudo apt install golang
This will add a repository with an updated version of GO and install it.
To test if GO is installed properly, type the following into terminal:
go version
This should provide the following output:
go version go1.9.2 linux/amd64
Now you can move on to the next step
Installing and setting up Git
We wouldn't get very far without installing and setting up Git. Version control of our code is vital to keeping track of changes. Here is a quick guide on how to get up and running with Git.
Ubuntu 16.04
In a terminal window, enter the following command:
sudo apt update && sudo apt install git
Next we need to set up user information so that you can create commits:
git config --global user.name "Your desired commit name"
git config --global user.email "yourName@mail.com"
Now you can make commits on your changes and have them tied to your name and email (this is required to commit with Git)
We can now move on....
Get a Copy of This Project
In order to work on this project, you will need a local copy of it. This can be done using git directly, but GO offers the ability to "go get" the project for us. This will be placed in /home/$USER/go/src
along with the proper domain it was pulled from (i.e gitbutter.pw), the owner (i.e Zolfite) and the name of the project.
The full path looks like: /home/$USER/go/src/gitbutter.pw/zolfite/project-rpg
The command to do all of this is as follows:
go get gitbutter.pw/zolfite/project-rpg
Next we go over setting up Visual studio code. You can use VSCode to open our project folder project-rpg
specified in the path above.
Install and Setup Visual Studio Code
Visual Studio Code or (VSCode) is an open source code suite developed by Microsoft Corporation under the MIT license. It is available for Windows, MacOS and Linux.
To get VSCode for Ubuntu 16.04, we simply have to download and install the .deb file.
- Open your Web Browser and go to: https://code.visualstudio.com/
- Click the green box in the middle of the screen that says ".deb"
If you are using Firefox, make sure to check the button "Save File"
If you are using Google Chrome, the file should download to your Downloads folder.
Next I recommend getting the "Gdebi Package Installer" since it is the most straight forward way to install a deb package.
sudo apt install gdebi-gtk
Then open your file manager and go to your downloads folder and:
- Right click the deb file for "code" that you downloaded earlier
- From the context menu choose "Gdebi Package Installer"
- Enter your user password when prompted
- Once Gdebi is finished, you can close the Window
- Now you can open Visual Studio Code from your applications menu
VSCode GO extension
Now you are ready to get the GO Extension to provide robust functionality for GO in VSCode.
When VSCode is open, press the hotkeys:
ctrl+p
This will bring down the text navigation command window.
Next let's install the extension by entering the following command:
ext install lukehoban.Go
Next we need to reload the VSCode window contents.
ctrl+shift+p
In the command line box, enter the following command:
Reload Window
This will refresh VSCode and enable any newly installed extensions.
Using the GO extension
Once the GO Extension is installed, all you have to do now is open an existing .go file and follow the prompt.
- Click the
File
menu and selectOpen Folder
- Navigate to
/home/YourName/go/src/gitbutter.pw/zolfite/project-rpg
- Click open to open the folder
VSCode will ask if you want to install the first required tool of the GO extension OR to install all.
Make sure you choose "Install all"
This will use go itself to "go get" the required tools required for the extension to function.
You will notice that a terminal output window appears on the bottom of VSCode showing you the progress of the installation.
After this, you are ready to start writing GO applications in VSCode
Getting Pixel Library
First, make sure golang is installed by following the instructions above.
Then run the following command in terminal:
go get github.com/faiface/pixel
This will place the repository with dev files in:
/home/$USER/go/src/github.com/faiface/pixel
All that is required to use Pixel now is to simply import it in your go file:
import(
"github.com/faiface/pixel"
)
System Dev Files
Next, we need to get development files in order for Pixel to use OpenGL.
Ubuntu 16.04
sudo apt update
sudo apt install libx11-dev mesa-common-dev libxcursor-dev libxrandr-dev libxinerama-dev libgl1-mesa-dev libxi-dev
This allows the Pixel library to make calls to the system and render graphics.
Now you can follow the Pixel Tutorial on Github