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.

Easy Go Programming Setup for Windows

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

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

  3. 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

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

    gopathcmd

  4. 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

  5. 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

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

    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

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

gohelloworld

I hope this helps!

目录
相关文章
|
7月前
|
前端开发 JavaScript Linux
Sublime Text 3配置Go语言开发环境
【4月更文挑战第13天】本篇文章 Huazie 向大家介绍使用 Sublime Text 3搭建Go语言开发环境,并演示编译运行 Go语言代码
852 8
Sublime Text 3配置Go语言开发环境
|
7月前
|
测试技术 API 开发者
【Docker项目实战】在Docker环境下部署go-file文件分享工具
【2月更文挑战第15天】在Docker环境下部署go-file文件分享工具
177 1
|
2月前
|
Unix Linux Go
Linux 使用Yum安装Go和配置环境
Linux 使用Yum安装Go和配置环境
|
4月前
|
安全 Java Go
探索Go语言在高并发环境中的优势
在当今的技术环境中,高并发处理能力成为评估编程语言性能的关键因素之一。Go语言(Golang),作为Google开发的一种编程语言,以其独特的并发处理模型和高效的性能赢得了广泛关注。本文将深入探讨Go语言在高并发环境中的优势,尤其是其goroutine和channel机制如何简化并发编程,提升系统的响应速度和稳定性。通过具体的案例分析和性能对比,本文揭示了Go语言在实际应用中的高效性,并为开发者在选择合适技术栈时提供参考。
|
4月前
|
JSON 缓存 监控
go语言后端开发学习(五)——如何在项目中使用Viper来配置环境
Viper 是一个强大的 Go 语言配置管理库,适用于各类应用,包括 Twelve-Factor Apps。相比仅支持 `.ini` 格式的 `go-ini`,Viper 支持更多配置格式如 JSON、TOML、YAML
100 0
go语言后端开发学习(五)——如何在项目中使用Viper来配置环境
|
5月前
|
运维 Serverless Go
函数计算产品使用问题之创建层时,如何添加Go环境
阿里云Serverless 应用引擎(SAE)提供了完整的微服务应用生命周期管理能力,包括应用部署、服务治理、开发运维、资源管理等功能,并通过扩展功能支持多环境管理、API Gateway、事件驱动等高级应用场景,帮助企业快速构建、部署、运维和扩展微服务架构,实现Serverless化的应用部署与运维模式。以下是对SAE产品使用合集的概述,包括应用管理、服务治理、开发运维、资源管理等方面。
|
4月前
|
Shell Go 开发工具
【Azure Developer】Go语言调用Azure SDK如何登录到中国区Azure环境
【Azure Developer】Go语言调用Azure SDK如何登录到中国区Azure环境
|
7月前
|
Unix Linux Go
Go 语言环境安装
Go 语言环境安装
50 1
|
7月前
|
Go 开发者 开发工具
Intellij IDEA 配置 Go 语言开发环境
【4月更文挑战第14天】本篇文章 Huazie 向大家介绍使用 Intellij IDEA 搭建 Go 语言开发环境,并演示编译运行Go语言代码
566 1
Intellij IDEA 配置 Go 语言开发环境
|
7月前
|
IDE Go 开发工具
【GO基础】2. IDEA配置Go语言开发环境
【GO基础】2. IDEA配置Go语言开发环境
710 2