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 条评论
登录 后参与评论

相关文章

来自专栏杨建荣的学习笔记

生产环境sql语句调优实战第四篇(r2笔记41天)

生产中有一条sql语句消耗了大量的cpu资源,执行时间在18秒左右, Session:PRODBUSER (1560:61133)SQL ID:1hg2wcua...

2035
来自专栏Jerry的SAP技术分享

ABAP OPEN SQL里OPEN CURSOR和SELECT的比较

After the OPEN CURSOR statement, the database cursor is positioned in front of t...

3569
来自专栏Jackson0714

玩转PowerShell第一节——【后台任务处理】-技术&分享

2846
来自专栏张善友的专栏

在Windows上运行单节点的Cassandra

Cassandra可以安裝在很多系统上, 我是安装在windows server 2008 R2上,安装相当简单,只要把下载下来的压缩包解压缩放到一个目录下就可...

1968
来自专栏杨建荣的学习笔记

生产环境sql语句调优实战第九篇(r3笔记第34天)

生产环境中有一些sql语句是不定时炸弹,不声不响的运行着,可能相关的表很大,运行时间达数小时,甚至数天。 上周在生产环境中发现一条sql语句,运行时间几乎是按照...

3315
来自专栏乐沙弥的世界

ORA-19815,ORA-19809 :limit exceeded for recovery files

    数据库重新启动的时候,收到了ORA-19815的错误。从错误的提示来看,是由于闪回区的空间被填满导致无法成功启动。这种情形我们通常考虑的是清除归档日志,...

593
来自专栏数据库新发现

How to Install Orabm

http://www.eygle.com/special/How.to.Install.Orabm.TPC.htm

1213
来自专栏张善友的专栏

Windows Server AppFabric Beta 2 已经发布

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

1715
来自专栏布尔

游标清除重复数据

有时候导数据会把数据导重,需要根据某些信息清除掉重复数据,同学做信息机业务的,不小心把用户信息导重复了,造成不能发短信。我帮他写了个游标来清理重复数据。memb...

17610
来自专栏菩提树下的杨过

Oracle:ODP.NET Managed 小试牛刀

“ODP.NET Managed”发布已经有一段时间了,近期正好有一个新项目,想尝试用一下,参考园子里的文章:《.NET Oracle Developer的福音...

2136

扫码关注云+社区