So you heard about Go
awesomeness right? Awesome! Go
works pretty well in Windows too! Let's start off by installing Go
toolchain in your own Windows. I managed to have access to a Windows7
through a nearby cyber cafe but having a hard time finding Windows10
in my neighborhood across 2 town (Yikes!). Nevertheless, Windows10
should not be too different from it.
I use Ubuntu
/ Debian
and Mac
in my everyday work so hunting a Windows10
is really hard in my neighborhood. My friends are using Mac
as well.
This page is dedicated to a young talent who is picking up Go
on his journey at the remarkable age of 9. You inspired me. Special thanks to:
NOTE
This guide is equipped with A LOT of pictures. You're advisable to use Wifi to access this site.
Our highest priority is to install Go
and its necessary software here. Go
has a dependency which is git. Hence, there are a minimum of 2 installations. As for a software to edit our code, we need to get one, which is Notepad++
. Therefore, our objectives are:
Git
, the Go
dependencyGo
Notepad++
Git
and test itGo
and test itNotepad++
, configure, and then test itLet's begin!
Before we install any software, we have to learn our system first. There are 3 very important information we must know:
These information are important since today's software are packed in different "packages" to suit the cpu.
On Windows, we use a program called dxdiag
which can report detailed explanation about our computer. To do that:
START
RUN
) and type dxdiag
dxdiag
program.If you get a prompting that a driver checking, grant it a yes. Don't worry, it only reports the computer hardware.
Once the DirectX diagnostic tool reported its findings, check the "Windows X-bit version". You can also learn a lot about your computer here too!
If it mentions 64-bit, it 64-bit. Otherwise, it's 32-bit Windows.
If it mentions Intel/AMD processor, it means amd64 for 64 bit, i386 for 32 bit.
Note this information down, we'll need it for the installation. In software world, this is how we download the correct software package.
Now is we need to check we have enough space to install the tool-chains.
MY COMPUTER
and check the c:
drive size. We need:Go
, Git
, Notepad++
, and some space for you write your code)NOTE:
If you run short of free space, you might want to uninstall some software/game or delete some old files in your computer.
Now that we understand our system, it's time to install the dependency first: Git
. Go
uses Git
to get the source codes from the Internet. When we install a software, we must always find out what it depends on before installing it. Otherwise, the software might crash or worst, may not work properly in the future. Let's get started.
Head over to the https://git-scm.com/download/win to download the git software. The Download automatically works once you visit the website.
NOTE: in case the automatic download doesn't work, select the correct bit version to download manually. Don't go for thumb-drive edition. We don't need that.
The bit version is what we learned from Step #1. So if the dxdiag was reporting 64-bit, download the 64-bit version. Otherwise, the 32-bit.
Once the download is completed, you can proceed to install it. Let's double click the installer.
Select Run when prompted permission. If you got permission denied. You might need to talk to your admin (or your parent) to unlock it for you.
Every proper software has its licenses. This is to protect itself from certain use, say like someone sell it illegally. Hence, as a good software developer, it is a good habit to read through before you proceed to NEXT
.
Most of the default settings are good. Until one thing that you need to watch out: the unchecked Check daily for Git for Windows updates
option. We want that. Hence,
Check daily for Git for Windows updates
.NEXT
.Here, the default installation path is Git
. Let's not change it. Proceed by pressing NEXT
.
Now the installer wants us to select with editor to choose when we use git commit
. It like a writing a small contract stating
Hey, I'm commiting my codes into this software repository. These codes changes are from me.
I recommend using Notepad++
since we're going to install that editor later. Remember to change it. Once done, select NEXT
.
Now the install asks us whether to choose which type of command prompt to use. Go
uses the default Windows Command Prompt (cmd)
. Hence,
Use Git from the Windows Command Prompt
NEXT
Now the installer presents us a set of complicated settings. This is the security over Internet configuration. In Windows, we have an option to use Windows Secure Channel library or the OpenSSL library; To decide for it is kind of complicated. If in doubt, stick to default, which is:
Use the OpenSSL Library
NEXT
Now Git
wants us to decide the ending format for commit message. Ending format is a symbol (\r\n
, \n
, \r
) to indicate a new line is created. It is also known as "End of Line".
Since almost all Git
users and developers alway use Unix system for automation and deployment, it is best to choose the ending with Unix-Style. Hence,
Checkout Windows-style, commit Unix-style line ending
NEXT
Now Git
is asking us to enable some features that Windows doesn't have. We can leave the default on and finally! proceed with Install
.
Installation has begun. Let's go grab some cookie and some exercise while waiting for it to complete.
Now that the installation is completed, It's time to test it out.
Launch Git Bash
FINISH
Well, we never know whether it is working or otherwise. Let's test it first. Once you press finish, a terminal immediately popup out.
Git
to see if the program is running properly.exit
on the next command.Remember that we need git to work in Windows Command Prompt (cmd) as well? Now we're about to test it. Let's launch a CMD prompt.
START
Search
/ Run
cmd
. Then launch it.Repeat the same process again in this terminal.
git
exit
to close the cmd
.Now that we had completed our Git
installation, it's time to install the main course: Go
! Let's begin its installation and try some stuff out!
Head over to https://golang.org/dl/. Select the correct msi
package based on what we learned from the computer (Step #1). Ensure you choose the stable version
, and the latest
too! Remember:
Now that we have the package, let's install it! Since you know how to install Git
already, give Go
a try on your own. It's the same process to install Git
.
Now that we have Go
installed, there are some minor setup we need to do before proceeding to use it. Let's start by bringing out our windows command prompt (cmd
).
START
> search
/run
> cmd
). In the command, type go env
. It should gives you a list of settings. GOPATH
, it points to where the project location is. c:
drive.Users\<the name>
until it shows the correct location as the GOPATH
. In the screenshot, the user is called orange
so it shows orange
. You'll immediately notice that we don't have a go folder. That's where want to create it.New
Folder
go
" and press ENTER
. (note: go
is very sensitive, so make sure it is the same as GOPATH
. Typing Go
or gO
won't work.). Enter the go
folder you had created. You can select the address bar to check the address is the same as GOPATH
.new
> folder
. Name the folders:bin
src
pkg
Now that our project folder is ready, we may test it. Remember, all your go work is inside this folder, as stated in GOPATH
. Let's begin our testing.
cd %GOPATH%
go get github.com/golang/example/hello
. A proper response is a no-response.src
folder. You'll notice a folder github.com
is created. If you go in further, you'll see the source code. That means go is working fine now.%GOPATH%/bin/hello
in the terminal. You'll get a response. This means the hello
is compiled successfully. Congrats so far! go
is good now.Now that we know our go
is working fine, there is another setting we need to do: GOBIN
. If you notice, it's missing now. Let's setup and test it out.
START
> Control Panel
> System
> Advanced System Settings
Environment Variables
.New
for user variables.GOBIN
GOPATH
(shown in orange) but add a \bin
behind.OK
> OK
> OK
to accept the new creation.START
> search
/ run
> cmd
)go env
.GOBIN
is now having value.%GOBIN%/hello
again. You should get the same test result. This means the GOBIN
is configured properly! Hooray. Go
setup is finally completed!Now that we have the go up and running, we need an editor to write our code. I recommend you to use Notepad++
(the best so far) and it's free. Let's setup now.
We'll first download the Notepad++ from its official website. Proceed to https://notepad-plus-plus.org/download and download the latest version. Notepad++ works on Intel cpu. You just need to select the correct bit version.
Now we have the installer, we can proceed to double click and install it. Just like Go
, give it a try on your own. At the end of the installation. Notepad++
will launch itself to perform its self-testing. If you see the contents CHANGELOG
, hooray! You installed it successfully.
Now that we have a proper editor for coding, there is one small thing we need to set before going into coding. Since most Go
developers are using Linux or Mac, it's better to set the editor to those modes. Don't worry, you can always adjust accordingly.
Select Settings
> Preferences
Select New Document
> Set Unix OR Mac
> Close
to save.
Now that everything is ready, let's head back to the go source code. Remember the %GOPATH%/src
has github.com
folder? Let's check it out.
c:/Users/<username>/go/src/github.com/golang/sample/hello
.hello.go
is a blank white file, it means Notepad++
is not configured yet. Right click the file.Open
.NOTE:
If hello.go is recognized by Notepad++ (the file has a chameleon in it), you can skip all the following steps. Notepad++ is well configured and you're ready to code!
These steps are here just in case otherwise.
Always use the selected program to open this kind of file
.c:
> Program Files
OR c:
> Program Files (x86)
Notepad++
folder.notepad++
Open
OK
confirmation, press OK
.Once you see the Notepad++
opens up the hello.go file, you're ready now for creating go application!
There are some Go
packages that can help you filter and correct your code as you save them? Check out:
There are other ways to install Go:
Now that you completed setting up your Git
, Go
and Notepad++
in your Windows, you can now proceed to create your own go program. Nevertheless, happy coding!