What You Need
To work with Go, you only need three things:
To develop Web applications with Buffalo, you will also need two other pieces of software:
You should also install a C compiler, even if you do not write C code. Go and Node.js packages can use libraries that are written in C, and these packages will require a C compiler to install themselves.
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. Run this in a PowerShell window to update your PATH:
[Environment]::SetEnvironmentVariable("Path", $env:Path + ";$($env:HOMEDRIVE)$($env:HOMEPATH)\go\bin", [EnvironmentVariableTarget]::User)
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 "email@example.com"
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) <firstname.lastname@example.org>"
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. If you do not have a favourite text editor, Visual Studio Code and Atom are high-quality and customisable editors that have well-maintained plugins for Go. All of these editors are provided free of charge. If you would prefer to use an IDE, JetBrains offer GoLand as a commercial product.
Setting Up Atom
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.
If you are not sure which database product to use, install PostgreSQL. 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 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 _pgctl utility to manage PostgreSQL:
Installing a C Compiler
To install GCC using Scoop, enter this command in a PowerShell window:
scoop install gcc
To install Buffalo, enter this command in a PowerShell window:
go get -u -v github.com/gobuffalo/buffalo/buffalo
Once it is installed, use the buffalo utility to create and manage your Web applications.
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 has a built-in update system. It will automatically display a message when you should update either the editor, or one of the packages that you have installed.
To upgrade Buffalo, enter this command in a PowerShell window:
go get -u -v github.com/gobuffalo/buffalo/buffalo
The -u option means that if you already have a copy of Buffalo, it will be upgraded.