前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >5步搭建GO环境

5步搭建GO环境

作者头像
hbbliyong
发布2018-03-06 12:03:24
1K0
发布2018-03-06 12:03:24
举报
文章被收录于专栏:hbbliyonghbbliyong

Easy Go Programming Setup for Windows

Dec 23, 2014

I’ve had to do this more than once recently, so I figured I’d document the simple steps for setting up the Go programming language on Windows. Most of this is simple and straightforward. The only tricky part I found is setting up your GOPATH, which defines a convention for storing and building Go code you write and acquire from open source code repositories.

5 Simple Steps

Follow these five simple steps to install Go.

  1. Make sure you have both Git download and Mercurial download installed. With Go programming you’ll make heavy use of open source repositories.
  2. Download and install the latest 64-bit Go MSI distributable (which sets most of the environmental variables for you). https://golang.org/dl/
go1-4-windows-amd64-msi
go1-4-windows-amd64-msi

To make things simple, use the default installation path at C:\Go

  1. Ensure the Go binaries (found in C:\Go\bin) are in your Path system environment variables. To check click System, Advanced system settings, Environment Variables... and open Path under System variables:
gopath
gopath

An easy way to confirm is to open the command line and type go version:

gopathcmd
gopathcmd
  1. Setup your Go workspace. This consists of three folders at the root: bin/ pkg/ src/ I create a C:\Projects\Go folder as my root Go workspace:
goworkspace
goworkspace
  1. Create the GOPATH environment variable and reference your Go workspace path. To add, click System, Advanced system settings, Environment Variables... and click New... under System variables:
gopathenvvar
gopathenvvar

Set the variable name to GOPATH and value to your Go workspace path (e.g. C:\Projects\Go):

gopathvalue
gopathvalue

You can quickly check to ensure your path has been set by opening the command line and typing echo %GOPATH% and check the output:

gopathecho
gopathecho

And that’s all it takes! You’re ready to get started.

Verify

Want to quickly test and ensure this is all working as expected? Open the command line and type the following:

代码语言:javascript
复制
go get github.com/golang/example/hello
%GOPATH%/bin/hello

You should see the output as “Hello, Go examples!” (refreshingly, not your typical hello world):

gohelloworld
gohelloworld

I hope this helps!

本文参与 腾讯云自媒体分享计划,分享自作者个人站点/博客。
原始发表:2017-02-05 ,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 作者个人站点/博客 前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体分享计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
目录
  • Easy Go Programming Setup for Windows
    • 5 Simple Steps
      • Verify
      领券
      问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档