golang 环境搭建
下载地址:https://golang.google.cn/dl/
下载:go1.10.3.windows-amd64.msi
安装
新建文件
环境配置
查看环境变量
GOROOT : golang安装目录 D:\Go
GOPATH :保存源码路径,开发代码路径,如F:\work\goCode
在环境变量 PATH下添加 : D:\Go\bin 和 F:\work\goCode\bin
重启cmd
Linux 下环境变量设置
export GOROOT=/opt/go
export GOPATH=/home/ubuntu/goCode
export PATH=$PATH:$GOROOT/bin:$GOPATH/bin
测试环境
在 F:\work\goCode\src\HelloWorld 目下新建 main.go文件,编写如下代码
package mainimport("fmt"
)func main(){fmt.Println("Hello World")
}
运行main.go
编译
在目录下生成
安装
自动生成文档
浏览器输入
在线查看文档
http://godoc.org/github.com/golang/protobuf/proto
IDE 环境安装
安装 vs code 及 golang 插件
VSCode 下载 : https://code.visualstudio.com/
安装:VSCodeUserSetup-x64-1.26.1.exe
查看版本号:cmd运行
go version
安装 go 插件
安装第三方插件,进行智能提示,debug等。
部分安装成功
输出信息如下:
Installing 10 tools at F:\work\goCode\bin
gocode
gopkgs
go-outline
go-symbols
guru
gorename
dlv
godef
goreturns
golint
Installing github.com/mdempsky/gocode SUCCEEDED
Installing github.com/uudashr/gopkgs/cmd/gopkgs SUCCEEDED
Installing github.com/ramya-rao-a/go-outline FAILED
Installing github.com/acroca/go-symbols FAILED
Installing golang.org/x/tools/cmd/guru FAILED
Installing golang.org/x/tools/cmd/gorename FAILED
Installing github.com/derekparker/delve/cmd/dlv SUCCEEDED
Installing github.com/rogpeppe/godef SUCCEEDED
Installing github.com/sqs/goreturns FAILED
Installing github.com/golang/lint/golint FAILED
6 tools failed to install.
go-outline:
Error: Command failed: D:\Go\bin\go.exe get -u -v github.com/ramya-rao-a/go-outline
github.com/ramya-rao-a/go-outline (download)
Fetching https://golang.org/x/tools/go/buildutil?go-get=1
https fetch failed: Get https://golang.org/x/tools/go/buildutil?go-get=1: dial tcp 216.239.37.1:443: connectex: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond.
package golang.org/x/tools/go/buildutil: unrecognized import path "golang.org/x/tools/go/buildutil" (https fetch: Get https://golang.org/x/tools/go/buildutil?go-get=1: dial tcp 216.239.37.1:443: connectex: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond.)
github.com/ramya-rao-a/go-outline (download)
Fetching https://golang.org/x/tools/go/buildutil?go-get=1
https fetch failed: Get https://golang.org/x/tools/go/buildutil?go-get=1: dial tcp 216.239.37.1:443: connectex: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond.
package golang.org/x/tools/go/buildutil: unrecognized import path "golang.org/x/tools/go/buildutil" (https fetch: Get https://golang.org/x/tools/go/buildutil?go-get=1: dial tcp 216.239.37.1:443: connectex: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond.)
go-symbols:
Error: Command failed: D:\Go\bin\go.exe get -u -v github.com/acroca/go-symbols
github.com/acroca/go-symbols (download)
Fetching https://golang.org/x/tools/go/buildutil?go-get=1
https fetch failed: Get https://golang.org/x/tools/go/buildutil?go-get=1: dial tcp 216.239.37.1:443: connectex: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond.
package golang.org/x/tools/go/buildutil: unrecognized import path "golang.org/x/tools/go/buildutil" (https fetch: Get https://golang.org/x/tools/go/buildutil?go-get=1: dial tcp 216.239.37.1:443: connectex: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond.)
github.com/acroca/go-symbols (download)
Fetching https://golang.org/x/tools/go/buildutil?go-get=1
https fetch failed: Get https://golang.org/x/tools/go/buildutil?go-get=1: dial tcp 216.239.37.1:443: connectex: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond.
package golang.org/x/tools/go/buildutil: unrecognized import path "golang.org/x/tools/go/buildutil" (https fetch: Get https://golang.org/x/tools/go/buildutil?go-get=1: dial tcp 216.239.37.1:443: connectex: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond.)
guru:
Error: Command failed: D:\Go\bin\go.exe get -u -v golang.org/x/tools/cmd/guru
Fetching https://golang.org/x/tools/cmd/guru?go-get=1
https fetch failed: Get https://golang.org/x/tools/cmd/guru?go-get=1: dial tcp 216.239.37.1:443: connectex: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond.
package golang.org/x/tools/cmd/guru: unrecognized import path "golang.org/x/tools/cmd/guru" (https fetch: Get https://golang.org/x/tools/cmd/guru?go-get=1: dial tcp 216.239.37.1:443: connectex: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond.)
Fetching https://golang.org/x/tools/cmd/guru?go-get=1
https fetch failed: Get https://golang.org/x/tools/cmd/guru?go-get=1: dial tcp 216.239.37.1:443: connectex: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond.
package golang.org/x/tools/cmd/guru: unrecognized import path "golang.org/x/tools/cmd/guru" (https fetch: Get https://golang.org/x/tools/cmd/guru?go-get=1: dial tcp 216.239.37.1:443: connectex: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond.)
gorename:
Error: Command failed: D:\Go\bin\go.exe get -u -v golang.org/x/tools/cmd/gorename
Fetching https://golang.org/x/tools/cmd/gorename?go-get=1
https fetch failed: Get https://golang.org/x/tools/cmd/gorename?go-get=1: dial tcp 216.239.37.1:443: connectex: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond.
package golang.org/x/tools/cmd/gorename: unrecognized import path "golang.org/x/tools/cmd/gorename" (https fetch: Get https://golang.org/x/tools/cmd/gorename?go-get=1: dial tcp 216.239.37.1:443: connectex: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond.)
Fetching https://golang.org/x/tools/cmd/gorename?go-get=1
https fetch failed: Get https://golang.org/x/tools/cmd/gorename?go-get=1: dial tcp 216.239.37.1:443: connectex: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond.
package golang.org/x/tools/cmd/gorename: unrecognized import path "golang.org/x/tools/cmd/gorename" (https fetch: Get https://golang.org/x/tools/cmd/gorename?go-get=1: dial tcp 216.239.37.1:443: connectex: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond.)
goreturns:
Error: Command failed: D:\Go\bin\go.exe get -u -v github.com/sqs/goreturns
github.com/sqs/goreturns (download)
Fetching https://golang.org/x/tools/imports?go-get=1
https fetch failed: Get https://golang.org/x/tools/imports?go-get=1: dial tcp 216.239.37.1:443: connectex: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond.
package golang.org/x/tools/imports: unrecognized import path "golang.org/x/tools/imports" (https fetch: Get https://golang.org/x/tools/imports?go-get=1: dial tcp 216.239.37.1:443: connectex: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond.)
github.com/sqs/goreturns (download)
Fetching https://golang.org/x/tools/imports?go-get=1
https fetch failed: Get https://golang.org/x/tools/imports?go-get=1: dial tcp 216.239.37.1:443: connectex: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond.
package golang.org/x/tools/imports: unrecognized import path "golang.org/x/tools/imports" (https fetch: Get https://golang.org/x/tools/imports?go-get=1: dial tcp 216.239.37.1:443: connectex: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond.)
golint:
Error: Command failed: D:\Go\bin\go.exe get -u -v github.com/golang/lint/golint
github.com/golang/lint (download)
Fetching https://golang.org/x/lint?go-get=1
https fetch failed: Get https://golang.org/x/lint?go-get=1: dial tcp 216.239.37.1:443: connectex: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond.
package golang.org/x/lint: unrecognized import path "golang.org/x/lint" (https fetch: Get https://golang.org/x/lint?go-get=1: dial tcp 216.239.37.1:443: connectex: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond.)
github.com/golang/lint (download)
Fetching https://golang.org/x/lint?go-get=1
https fetch failed: Get https://golang.org/x/lint?go-get=1: dial tcp 216.239.37.1:443: connectex: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond.
package golang.org/x/lint: unrecognized import path "golang.org/x/lint" (https fetch: Get https://golang.org/x/lint?go-get=1: dial tcp 216.239.37.1:443: connectex: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond.)
发现代码都下载成功,但部分未安装
重新安装
新建如下目录 F:\work\goCode\src\golang.org\x
在 F:\work\goCode\src\golang.org\x 目录下 git 获取代码
git clone http://github.com/golang/tools
git clone http://github.com/golang/lint
下载完成后,在F:\work\goCode目录下执行cmd命令
go install golang.org/x/tools/cmd/gorename
go install golang.org/x/tools/cmd/guru
go install github.com/ramya-rao-a/go-outline
go get -u -v github.com/newhook/go-symbols 下载成功,但没有安装,用下面命令手动安装
go install github.com/newhook/go-symbols
go install github.com/sqs/goreturns
go get -v -u github.com/peterh/liner github.com/derekparker/delve/cmd/dlv
上面安装的包也可以通过以下方式下载:
go get -u -v github.com/nsf/gocode
go get -u -v github.com/rogpeppe/godef
go get -u -v github.com/tpng/gopkgs
go get -u -v golang.org/x/tools/cmd/gorename
go get -u -v golang.org/x/tools/cmd/guru
go get -u -v github.com/ramya-rao-a/go-outline
go get -u -v github.com/newhook/go-symbols
go get -u -v sourcegraph.com/sqs/goreturns
go get -u -v github.com/golang/lint/golint
F5 debug 调试插件
go get -v -u github.com/peterh/liner github.com/derekparker/delve/cmd/dlv
这些内容最终目的是要在gopath中bin文件夹中生成一些exe文件。
配置 VSCode
在用户设置中粘贴如下 json 语句
{
"go.buildOnSave": true,
"go.lintOnSave": true,
"go.vetOnSave": true,
"go.buildTags": "",
"go.buildFlags": [],
"go.lintFlags": [],
"go.vetFlags": [],
"go.coverOnSave": false,
"go.useCodeSnippetsOnFunctionSuggest": false,
"go.formatOnSave": true,
"go.formatTool": "goreturns",
"go.goroot": "D:\\Go",
"go.gopath": "F:\\work\\goCode",
"go.gocodeAutoBuild": false
}
测试
golang 环境搭建相关推荐
- golang环境搭建之centos篇
目录 步骤一.安装centos7虚拟机 1.VMwear安装Centos7超详细过程. 2.装完Centos7提示Initial setup of CentOS Linux 7 (core). 步骤二 ...
- linux环境搭建golang服务器,Linux下golang环境搭建-Go语言中文社区
1.首先从使用wget https://storage.googleapis.com/golang/go1.12.linux-amd64.tar.gz命令下载安装包,可以根据自己的需要选择版本. 2. ...
- golang | windows平台golang环境搭建(过坑之后)
文章目录 背景 golang安装 环境变量的配置 开发环境环境 VSCode配置 背景 我所处的环境 windows10(详细版本无所谓) go最新版本 vscode编辑器(非IDE,IDE为gola ...
- golang SDK环境搭建
在学习golang前,我们必须把本地的golang 开发环境配置好,否则后面也没法玩起.下面我们分别来学习windows.mac下 golang环境搭建. windows 下载可执行二进制包安装 下载 ...
- Golang开发环境搭建-Vim篇
Golang开发环境搭建-Vim篇 转自:http://tonybai.com/2014/11/07/golang-development-environment-for-vim/ 虽说sublime ...
- golang 学习心得一(开发环境搭建过程中一些坑)
最近刚接触golang,除了被go的语法吸引之外,在搭建go开发环境过程才也遇到一些问题,现在写出来和大家分享,希望以后对go有兴趣的初学者能避免我的弯路. Sublime Text 环境搭建,这个有 ...
- Golang (Go语言) Mac OS X下环境搭建 环境变量配置 开发工具配置 Sublime Text 2 【转】...
一.安装Golang的SDK 在官网 http://golang.org/ 直接下载安装包安装即可.下载pkg格式的最新安装包,直接双击运行,一路按照提示操作即可完成安装. 安装完成后,打开终端,输入 ...
- Golang开发环境搭建
文章目录 Golang的诞生 Golang的核心开发团队 Golang里程碑 Golang应用领域 使用Golang开发的项目 环境搭建 Golang SDK下载及安装 Golang IDE下载及安装 ...
- 从零开始搭建EasyDarwin环境——Linux系统开发环境Golang的搭建
EasyDarwin在语言上服务端使用的是Golang,前端网页是vue.因此我们需要有Golang和node的开发环境.本章我们将说明一下如何在Linux下搭建Golang环境. 1.下载 执行以下 ...
最新文章
- java 之 正则表达式
- flutter设置文本最大宽度
- asp.net 中GridView控件实现全选及反选的功能
- php 判定pc端與移動端
- 如何循序渐进向DotNet架构师发展
- 如何给SAP Cloud Connector Region列表中添加新的Region
- 【clickhouse】clickhouse 配置 安装目录
- ArcGIS Maritime Server 开发教程(三)Maritime Service 功能解读
- Sass--占位符 %placeholder
- 蚂蚁课堂视频笔记思维导图-3期 九、分布式缓存架构
- 集成电路制造工艺及设备
- 5G协议演进(包括3GPP协议版本)
- 办公必备的WPS Office 2021 for mac(wps 2021中文版)
- 【旺铺2012分享】导航CSS代码使用修改技巧!
- 注册gmail邮箱手机号无法验证
- cidaemon.exe过程cpu入住率和关闭cidaemon.exe加工方法
- IDEA代码放大缩小快捷键设置、注释、标识符以及关键字。
- 初识ELK(日志系统)
- 《光剑教教义:五信 九训 十诫 九罪》
- VBA Excel 直接增加任意名字sheet