5步搭建GO环境

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/

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:

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

  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:
  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:

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

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

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:

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):

I hope this helps!

本文参与腾讯云自媒体分享计划,欢迎正在阅读的你也加入,一起分享。

发表于

我来说两句

0 条评论
登录 后参与评论

相关文章

来自专栏图像识别与深度学习

《Android》Lesson16-Fragment

1466
来自专栏跟着阿笨一起玩NET

OpenFileDialog Filter属性设置所有图片格式

351
来自专栏张善友的专栏

Windows Server AppFabric Beta 2 已经发布

Windows Server AppFabric Beta 2是一个包含完全功能的AppFabric版本(This build represents our “...

1685
来自专栏WD学习记录

Leetcode Container With Most Water

Given n non-negative integers a1, a2, ..., an , where each represents a point at...

443
来自专栏数据库新发现

Emulex光纤卡lpfc配置文件的修改

# cd /kernel/drv # vi sd.conf "sd.conf" 65 lines, 1611 characters # # Copyright...

882
来自专栏debugeeker的专栏

确定core文件是由哪个文件产生的方法

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/xuzhina/article/detai...

262
来自专栏北京马哥教育

LVM创建实例及相关注释

LVM创建 pv—>vg—->lv—->快照 创建前准备了四块1g硬盘分别为:sdb sdc sdd sde,并分别给四块盘划分了1G的空间,并指定了分区系统类...

25912
来自专栏潇涧技术专栏

Head First Stanford NLP (1)

(深入浅出Stanford NLP 基础篇) 本文主要介绍Stanford NLP工具的基本使用方法。

652
来自专栏用户2442861的专栏

How to install cmake 3.2 on ubuntu 14.04? caffe安装错误的解决

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/haluoluo211/article/details...

562
来自专栏北京马哥教育

Linux ext4无法使用超过16T磁盘的解决办法

系统环境:Centos6.7 x86_64 己updte 磁盘:12*4T raid5 +hot 说明:操作系统与归档都使用同一个raid5 应用环境:邮局系统...

3356

扫描关注云+社区