Skip to content

Instantly share code, notes, and snippets.

@jcbwlkr
Last active April 30, 2020 20:26
Show Gist options
  • Save jcbwlkr/2cbe72427f9cbc41bfbb7972d62429d8 to your computer and use it in GitHub Desktop.
Save jcbwlkr/2cbe72427f9cbc41bfbb7972d62429d8 to your computer and use it in GitHub Desktop.
Getting Set Up With Go On Windows

Go On Windows

Installing Go

  1. Go to https://golang.org/dl/ and download the installer for your OS.
  2. Run the installer and accept all default prompts.
  3. Create a folder called "Projects" in your home folder.
  4. In the start menu search for env then select "Edit environment variables for your account".
  5. Add a new variable called GOPATH with a value of %USERPROFILE%\Projects.
  6. Edit the PATH variable and add this to whatever is already there ;%GOPATH%\bin.
  7. In the start menu search for cmd then run it.
  8. In the cmd window run go env. You should see the GOPATH variable you set.
  9. Close that cmd window

Install Git

Git is required to use the go get feature to install projects hosted on github or other Git based services.

  1. Do a Google search for "git for windows" and go to the first one. It should be https://git-scm.com/download/win
  2. Download and run the installer. I would check the boxes to add additional desktop icons. When prompted leave the default choice of "Use Git From the Windows Command Prompt".

Test Our Installation

Open a cmd window and run go get github.com/golang/lint/golint.

After that is done run golint -h and see if it works. It should give you the help message for a program called golint. If this does not work then you've likely misconfigure the PATH or GOPATH variables so go back and check those.

Installing an editor

  1. Go to https://code.visualstudio.com/ and download the installer.
  2. Run the installer. I would check the boxes to add to context menus.
  3. Let Code launch after installation (or launch it yourself).
  4. Open the command palette with ctrl-shift-p
  5. Start typing "install extension" and choose that option
  6. Choose the Go extension. It will go away then after a minute say 'Go' was successfully installed. Restart to enable it. Choose to restart it.
  7. Open the HOME\Projects\src\github.com folder. Under that create a folder named your-username and under that create a folder named greet. In that folder create a file main.go and open it.
  8. In the bottom right a warning "Analysis Tools Missing" will show up. Click it then click "install" in the pop up window. Wait for it to stop printing anything.
  9. Open your editor preferences by going to File > Preferences > User Settings. Add this "go.formatOnSave": true
  10. Restart VS Code
@binuedwin
Copy link

Hi team,

I tried installing go in my windows and tried setting Go111Module=On. after doing this getting error.
a command used go env -w GO111MODULE=ON
go: unknown environment setting GO111MODULE=ON

After trying to uninstall and reinstall go also getting the same error.

Thanks,
Binu

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment