Configuring Development environment for Go-Lang in Windows 10

Techie Vee
techievee
Published in
4 min readNov 15, 2018
Photo by Fotis Fotopoulos on Unsplash

This guide is broadly classified as the following sections

  • Installing and configuring Go-Language
  • Installing Visual code and go-lang tools
  • Creating and running the first Go program
  • Installing and configuring GIT for SCM

Go language is getting increasing popularity as a general purpose programming. But often people face difficulty in effectively configuring the development environment as readily configured IDE such as Jetbrains Go are offered for charges. In this guide, i will be guiding a effective way to configure a perfect development setup for Go language using the free tools.

1. Installing and configuring Go

  • Go language binaries can be installed for windows using a installer that can be downloaded from the Go language site
    Download link
  • After running the installer, the go binaries can be found in the bin folder of the installation directory. By default the Go gets installed in c:\Go\bin
Go language executable binary
  • In order to make the Go to work properly, the following environment variable need to set properly

GOROOT
GOPATH

Navigate to system environment variable settings via
Control Panel->System->Advanced System Settings->Environment variables

GOROOT → This variable defines the path where the go binary exists. Its a variable that points to your Go installation directory. By default its C:\Go

GOPATH → GoPath contains a work-space where your Go programs resides. Its advisable to have a different Workplace directory. The directory should contains the following folders. You need to forcefully create the following folder to have your projects setup
— src
— pkg
— bin

Directory structure
  • After setting the environment variable, you need to restart the system for the variable to apply.
  • To test the working of go language, open command prompt and type
    go version
go version check

Note: If you have any problem getting the version, it denotes some error with the environment variables.

2. Installing Visual Studio Code and Tools

Visual Studio Code is source code editor, which can be integrated to various tools and has a wide tools available to support various commonly used languages.
It can be downloaded here

Perform the installation and open the Visual Studio Code.

Click on the extension icon on the left and search for Go, Click install and reload the editor after installation

Go tools installation

After installing the main plugin, the additional tools gets installed as and when it is required. To get started with the other tool installation, create a new project and run the program.

It prompts you for missing tools and gives you the option to Install it. Install one by one, wait for installation of one tool to get completed.

3. Creating and running a Go program

The following section demonstrates a way to create and run a your first go program.

  • Open Visual studio
  • File -> open folder ->< GOPATH directory> ( It can be any directory that is lying inside the GOPATH)
  • Create a new file and save it with extension .go
creating a new go program

As you hit ctrl + s it prompts you to install any additional required tools, Install every tool one by one.

  • To debug the programs, “delve” need to be installed.
  • open the command prompt and type

go get -u github.com/derekparker/delve/cmd/dlv

  • It would download the delve package into the configured GOPATH directory.
  • Now you can set the breakpoints or watch variable by clicking the play button or Debug ->start debugging or F5
Sample Go Program output

4. Installing and configuring GIT for SCM

GIT is a popular source code management tool for the open source project. In this section, we would see the way to integrate your project to the Github.com

  • For windows to perform the basic GIT operation we need the “Git software”, that enables basic GIT commands for the windows environment.
    Download the software here
  • If you are not having a account in the Github.com, create a new account.
  • The username and email need to be set through GIT commands for making use of the functionality and to enable identity of the endpoints.
  • To set the Global configuration, use the following
git config --global user.name "FIRST_NAME LAST_NAME"git config --global user.email "MY_NAME@example.com"
  • Now click the View-> SCM to get the SCM pane, where you can create a repository or pull a repository and start working on it
SCM Integration

Finally, full IDE for Go language is created with integrated SCM.

Photo by Xan Griffin on Unsplash

--

--