61 Star 341 Fork 415

infraboard / go-course

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
install.md 3.71 KB
一键复制 编辑 原始数据 按行查看 历史
Mr.Yu 提交于 2021-06-18 11:04 . merge

开发环境搭建

在线体验

在线演练地址: https://play.golang.org/

安装Go

参考官方文档: https://golang.org/doc/install

安装包下载地址:

go_pkg

安装完成后执行命令, 能看到当前安装的go的版本,恭喜你,go安装成功:

go version
go version go1.16.4 windows/amd64

安装Git

先安装git, 准备好git shell 具体查看官方文档: https://git-scm.com/

windows_git

开发工具

  • Visual Studio code
  • Sublime Text
  • Atom
  • Eclipse+GoClipse
  • LiteIDE
  • Goland
  • Vim
  • Emacs
  • ……

vscode 开发环境搭建

vscode官网下载最新版: https://code.visualstudio.com/

vscode_pkg

安装Vscode Go语言扩展

vscode_ext_go

安装Go 语言扩展需要的工具集

这些扩展很多被墙了, 需要配置GOPROXY代理才能正常安装:

go env -w GOPROXY=https://goproxy.cn

设置变量过后为了保证vscode能正常使用, 请重启vscode

  1. 打开命令面板: Shift + Ctrl + P

  2. 输入: Install/Update 搜索 Go扩展依赖工具安装命令

vscode_ext_go_tools1

  1. 勾选所有选项, 点击确认,进行安装

vscode_ext_go_tools2

安装成功后会看到如下信息:

vscode_ext_go_tools3

2.如果安装失败也可以尝试手动安装

go install -v golang.org/x/tools/gopls@latest
go install -v honnef.co/go/tools/cmd/staticcheck@latest
go install -v github.com/go-delve/delve/cmd/dlv@latest
go install -v github.com/haya14busa/goplay/cmd/goplay@latest
go install -v github.com/josharian/impl@latest
go install -v github.com/fatih/gomodifytags@latest
go install -v github.com/cweill/gotests/gotests@latest
go install -v github.com/ramya-rao-a/go-outline@latest
go install -v github.com/uudashr/gopkgs/v2/cmd/gopkgs@latest

设置终端使用Git Shell (Mac和Linux开发环境的同学忽略此步骤,该步骤仅针对Windows环境)

  1. Shift + Ctrl + ` 打开终端

  2. 打开终端的设置界面

open_vscode_term

  1. 修改terminal.integrated.shell.windows和terminal.integrated.defaultProfile.windows 为如下值
{
    "workbench.colorTheme": "One Dark Pro",
    "terminal.integrated.shell.windows": "C:\\Program Files\\Git\\bin\\bash.exe",
    "go.useLanguageServer": true,
    "explorer.confirmDelete": false,
    "explorer.confirmDragAndDrop": false,
    "workbench.iconTheme": "vscode-icons",
    "vsicons.dontShowNewVersionMessage": true,
    "http.proxySupport": "off",
    "go.toolsManagement.autoUpdate": true,
    "terminal.integrated.tabs.enabled": true,
    "terminal.integrated.defaultProfile.windows": "Git Bash",
    "git.autofetch": true,
}
  1. 重启vscode, 可以看到默认打开Git Bash终端、也可选择其他终端

windows_git_bash

如果你还不会,可以看看我们勤奋的学员的博客: VS Code 终端设置为Git Bash

插件安装

  • 单词拼写检查: Code Spell Checker

  • 快捷运行代码的插件: Code Runner

code_runner

  • 最好用Git工具没有之一: Gitlens

gitlens

  • AI 代码生成: Tabnine AI Code

配置自动保存

auto_save

如果要配置自动保存的时间, 打开vscode的设置按钮, 搜索auto save

auto_save_config

Go
1
https://gitee.com/infraboard/go-course.git
git@gitee.com:infraboard/go-course.git
infraboard
go-course
go-course
master

搜索帮助