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); } ...

2364
来自专栏后端之路

基于SpringBoot的CodeGenerator

背景 目前组织上对于一个基础的crud的框架需求较多 因此选择了SpringBoot作为基础选型。 Spring Boot是由Pivotal团队提供的全新框架,...

1.4K11
来自专栏SpringBoot

springboot + jpa + redis + hibernate validator + 后台抽象

项目码云地址:https://gitee.com/DencyCheng/admin-api

611
来自专栏技术专栏

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

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

4843
来自专栏石奈子的Java之路

原 荐 SpringBoot 2.0 系列0

2603
来自专栏Java与Android技术栈

使用 Kotlin + Spring Boot 进行后端开发Kotlin示例一:结合 Redis 进行数据存储和查询示例二:结合 RxJava 模拟顺序、并发地执行任务总结

Kotlin 是一个基于 JVM 的编程语言,它的简洁、便利早已不言而喻。Kotlin 能够胜任 Java 做的所有事。目前,我们公司 C 端 的 Androi...

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

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

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

2122
来自专栏后端之路

jsp改造之sitemesh注意事项

背景 现在各种现代化的浏览器确实惯坏了开发者 智能纠错 无论是忘记关闭标签甚至重复等等都有可能被chrome这些浏览器智能纠错===》chrome会合并多个bo...

2494
来自专栏光变

SpringMVC 异步提交表单数据

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

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

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

1825

扫码关注云+社区