What You Need
To work with Go, you only need three things:
To develop Web applications, you will also need some other pieces of software:
- A database, such as SQLite or PostgreSQL
- A compiler for C, so that downloaded C libraries will build on your computer
Go, Node.js and many other systems can use libraries that are written in C, so you should install GCC even if you do not write C code.
Rather installing and updating these tools yourself, use a package manager. This tutorial explains how to set up the Scoop package manager and have it install the other software that you need.
If you download and install software yourself, always choose the 64-bit version. Only use 32-bit versions of Windows software if you know that you are using a 32-bit computer.
Setting Up the Scoop Package Manager
First, run this command in a PowerShell window:
Set-ExecutionPolicy RemoteSigned -scope CurrentUser
Press A when prompted. This ensures that PowerShell can run Scoop.
Enter this command in PowerShell to install Scoop:
iex (new-object net.webclient).downloadstring('https://get.scoop.sh')
To install Go using Scoop, enter this command in a PowerShell window:
scoop install go
The Go tool will automatically create a folder called go in your user account when it is needed. This is your Go workspace. To ensure that Go applications run, you must add the bin folder in your workspace to your PATH:
- Open Control Panel
- Choose System and Security > System > Advanced System Settings
- Click Environment Variables…
- Select Path from the list of user variables and click Edit…
- Click New and enter: %HOMEPATH%\go\bin
- Click OK to exit
Installing the Git Version Control System
To install Git using Scoop, enter this command in a PowerShell window:
scoop install openssh git
If you do not use Scoop, go to the Git Web site and follow the link for Downloads to find a Windows installer.
Once you have installed Git on a system, set your details. These are automatically applied to every commit that you make. This requires two commands:
git config --global user.name "Your Name" git config --global user.email "firstname.lastname@example.org"
The global option means that the setting will apply to every repository that you work with in the current user account.
Creating SSH Keys
You will frequently use SSH to access Git repositories or remote UNIX systems. The Git package includes the standard OpenSSH suite of tools.
To create an SSH key, run the ssh-keygen command in a Git terminal window. For example:
ssh-keygen -t rsa -b 4096 -C "Me MyName (MyDevice) <email@example.com>"
Use 4096-bit RSA keys for all systems. The older DSA standard only supports 1024-bit keys, which are now too small to be considered secure.
Installing a Text Editor
The Notepad text editor in Windows is designed for light-weight word processing, and has no support for programming. Unless you already have a preferred editor, install Atom, which is a powerful Open Source text editor.
To install Atom, download the latest version from the project Website.
Current versions of Atom include support for Git. You will massively improve your experience with your text editor by installing a few more plugins to it.
To install Atom packages, either choose or use the apm command in a terminal window. Run this command to add the go-plus package, which turns Atom into a development environment for Go:
apm install go-plus
The next time that you open Atom, you will see go-plus automatically download and configure all of the tools that it needs. go-plus will ask you to restart Atom once for the changes to take effect.
Run this command to install other useful packages for Atom:
apm install file-icons linter-csslint linter-eslint linter-js-yaml
To install Node.js using Scoop, enter this command in a PowerShell window:
scoop install nodejs-lts
This installs the current LTS (Long-term Support) version of Node.js. The Node.js project provides other versions that are specifically for early-adopters.
If you do not use Scoop, go to the Node.js Web site and follow the link for Downloads to find a Windows installer.
SQLite creates SQL databases on demand, as files. This means that you can develop applications without running a database service on your computer. SQLite databases are intended for single-user systems, such as desktops and mobile devices. Avoid using SQLite for Web applications that will be deployed to servers. Use SQLite for desktop and command-line applications, or for learning purposes.
PostgreSQL is a full SQL database product with support for advanced features such as full-text search and JSON document storage. Use PostgreSQL for Web applications. The default configuration of PostgreSQL only uses a small amount of memory and CPU, so you can install it even on computers with limited resources.
To install SQLite using Scoop, enter this command in a PowerShell window:
scoop install sqlite
To install PostgreSQL using Scoop, enter this command in a PowerShell window:
scoop install postgresql
This does not create databases, or start the PostgreSQL service. Before you start the service, create the required directories and databases:
mkdir $env:HOMEPATH\pgsql\databases mkdir $env:HOMEPATH\pgsql\logs pg_ctl initdb -D $env:HOMEPATH\pgsql\databases
To start PostgreSQL:
pg_ctl -D $env:HOMEPATH\pgsql\databases -l $env:HOMEPATH\pgsql\logs\server.log
Once PostgreSQL is running, test it by logging in with the psql utility:
psql -d template1
This sets the working database as the standard template1 database. Once you have logged in, enter \q to exit the console.
Use the pg_ctl utility to manage PostgreSQL:
Installing a C Compiler
To install GCC using Scoop, enter this command in a PowerShell window:
scoop install gcc
Updating Your Tools
Use Scoop to upgrade your software as new versions become available.
To update the index of available packages, run this command in a PowerShell window:
To upgrade a specific application, give the name of the product as an option to the scoop update command. For, example this command upgrades Go:
scoop update go
To upgrade all of the software that Scoop manages, use an asterisk instead of the name of an application:
scoop update *
Atom and Visual Studio Code have their own update systems. They will automatically display a message when you should update the editor or one of the packages that you have installed.