---
title: "环境安装"
url: "https://goframe.org/docs/install-go/index"
markdown_url: "https://goframe.org/docs/install-go/index.md"
locale: "zh-Hans"
version: "2.10.x(Latest)"
section: "其他资料"
category: "其他资料 / 准备开发环境"
published: "2024-10-27"
updated: "2026-01-30"
description: "手把手的Golang开发环境和IDE配置教程，适合Golang初学者。详细介绍了如何下载和安装Go开发包，并推荐使用JetBrains的Goland作为开发IDE，支持GoFrame框架开发。此外，还包括VSCode的安装和使用步骤，帮助用户快速构建第一个Go程序。"
keywords: ["GoFrame", "Go开发", "Golang安装", "Go环境配置", "Goland", "VSCode", "IDE设置", "JetBrains", "Go程序", "GoFrame框架"]
---

# 环境安装

该章节为手摸手安装 `Golang` 开发环境及 `IDE` 配置教程，仅针对 `Golang` 萌新，老司机请忽略。

## Go开发环境安装

### Step1 - 下载Go开发包

访问`Go`国内镜像站下载页面 [https://golang.google.cn/dl/](https://golang.google.cn/dl/)，并在页面最上方的版本中选择你当前的系统版本，会下载最新版本的`Go`开发包:

![](https://goframe.org/markdown/d3ce7f0e43ebf678adea8db4c46662d5.png)

### Step2 - 安装引导

访问官方安装介绍页面 [https://golang.google.cn/doc/install](https://golang.google.cn/doc/install)，按照当前系统版本执行对应的安装流程即可。

Windows( `msi`)和MacOS( `pkg`)推荐使用安装包的方式来安装。作者当前MacOS安装包( `pkg`)安装过程如下图所示：

![](https://goframe.org/markdown/80729ac6360ac646a39b696d32778d66.png)

![](https://goframe.org/markdown/afc21d8598a0bef86c1a53c8e6784bb6.png)

![](https://goframe.org/markdown/f3f59daf118e34e16a920bcdcf6391de.png)

`Go`的开发包升级也是同样的过程。

## IDE开发环境安装

目前 `Go` 的 `IDE` 有两款比较流行，一款是 `VSCode+Plugins`（免费），另一款是 `JetBrains` 公司的 `Goland`（收费）。由于 `JetBrains` 也是 `GoFrame` 框架的赞助商，因此我们这里优先推荐使用 `Goland` 来作为开发IDE，下载及注册请参考网上教程（ [百度](https://www.baidu.com/s?wd=goland%20安装) 或 [Google](https://www.google.com/search?q=goland+安装)）。

`JetBrains` 的官方网站为： [https://www.jetbrains.com](https://www.jetbrains.com/?from=GoFrame)

### Goland的使用

我们来创建第一个 `Go` 程序吧，老规矩，上 `hello world`。

#### Step1. 打开IDE

![](https://goframe.org/markdown/53e952d14b92225b865b2bca6aab7cd2.png)

#### Step2. 创建项目

这里需要注意的是 `Go` 安装文件的路径( `SDK`)， [官方安装文档](https://golang.google.cn/doc/install) 有详细说明，请仔细阅读。

其中的 `Location` 随意选择一个本地路径即可。

![alt text](https://goframe.org/assets/images/QQ_1733020124554-f03a566143ecc642f52d6a9f9ff1e029.png)

#### Step3. 创建程序

编辑 `main.go`，并输入以下代码:

```go
package main

import "fmt"

func main() {
    fmt.Println("hello world!")
}
```

![alt text](https://goframe.org/assets/images/QQ_1733020331260-6dcfc230cebdbebe770e98e1285b830a.png)

#### Step4. 执行运行

菜单栏 `Run` - `Run` - `go build hello.go`。

![alt text](https://goframe.org/assets/images/QQ_1733020422698-820b07c1fd7f976e2597bd28db0c0701.png)

![alt text](https://goframe.org/assets/images/QQ_1733020474019-d84d57ae83bf72822dea0e8b2f515a56.png)

![alt text](https://goframe.org/assets/images/QQ_1733020511081-641e796b85aafd28e7bd493db1312910.png)

恭喜你，第一个 `Go` 程序便成功了！

### VSCode的使用

#### [Step1 - 下载安装](https://code.visualstudio.com/)

#### [Step2 - 安装Go扩展](https://docs.microsoft.com/zh-cn/learn/modules/go-get-started/4-install-visual-studio-code?ns-enrollment-type=learningpath&ns-enrollment-id=learn.languages.go-first-steps)

#### [Step3 - Hello World](https://docs.microsoft.com/zh-cn/learn/modules/go-get-started/5-hello-world)
