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

相关文章

来自专栏服务端技术杂谈

dubbo源码学习笔记----registry

注册工厂 public interface RegistryFactory { Registry getRegistry(URL url); } ...

2454
来自专栏光变

SpringMVC 异步提交表单数据

1952
来自专栏一个会写诗的程序员的博客

Kotlin集成 SpringBoot 混合Java库开发

apply plugin: 'org.springframework.boot' apply plugin: 'kotlin'

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

silverlight:ListBox中如何取得DateTemplate/ItemsPanelTemplate中的命名控件?

Xaml如下: <UserControl x:Class="ToolsTest.Test"     xmlns="http://schemas.microsof...

1885
来自专栏开发与安全

linux网络编程之System V 信号量(一):封装一个信号量集操作函数的工具

信号量的概念参见这里。 与消息队列和共享内存一样,信号量集也有自己的数据结构: struct semid_ds { struct ipc_perm sem_p...

3940
来自专栏owent

ZOJ 3309 Search New Posts 解题报告

题目链接:http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemCode=3309

493
来自专栏JAVA技术站

微信开发之网页获取用户信息 原

再通过redirect_uri指定回调地址跳转到getUserInfo接口获取用户信息

862
来自专栏技术专栏

logback日志写入kafka遇到的那些坑

这两天在学习storm实时流的时候需要将logback日志写入kafka,这期间遇到了很多坑,这里把遇到的坑和解决的问题记录一下,和大家共勉

9303
来自专栏java、Spring、技术分享

Spring Import 三种用法与源码解读

  最近在看Spring Cloud相关的源码,每次引入一个新的starter,发现都会加一些enable的注解,比如:@EnableDiscoveryClie...

1863
来自专栏Android源码框架分析

获取Android设备DeviceId与反Xposed Hook技术

APP开发中常需要获取设备的DeviceId,以应对刷单,目前常用的几个设备识别码主要有IMEI(国际移动设备身份码 International Mobile ...

3002

扫码关注云+社区