美文网首页
Go环境的安装

Go环境的安装

作者: 芒果奶油卷 | 来源:发表于2019-12-20 17:15 被阅读0次

一、安装

安装包下载地址为

https://golang.org/dl/

https://golang.google.cn/dl/

https://studygolang.com/dl

1.在windows下

安装完成后,配置环境变量:

GOROOT:Go语言的安装路径

GOPATH:Go语言的工作空间,不能与 GOROOT 相同(存放用户自己的源码文件)

Path: ;%GOROOT%\bin\ ; %GOPATH%\bin\

GoPath下应该有三个文件夹:

src :包含Go的源文件,它们被组织成包(每个目录都对应一个包)

pkg:包含包对象,也即编译好的库文件 *.a

bin:包含可执行命令

查看go的环境变量使用go env

2.在linux下

二、在gopath中增加bin文件(用于visual studio code)

新建文件,在文件中编写一下内容

mkdir %GOPATH%\\src\\golang.org\\xgit clone https://github.com/golang/tools.git %GOPATH%\\src\\golang.org\\x\\tools

go get -v github.com/mdempsky/gocode

go get -v github.com/uudashr/gopkgs/cmd/gopkgs

go get -v github.com/ramya-rao-a/go-outline

go get -v github.com/acroca/go-symbols

go get -v golang.org/x/tools/cmd/guru

go get -v golang.org/x/tools/cmd/gorename

go get -v github.com/derekparker/delve/cmd/dlv

go get -v github.com/stamblerre/gocode

go get -v github.com/rogpeppe/godef

go get -v github.com/ianthehat/godef

go get -v github.com/sqs/goreturns

%go get -v github.com/golang/lint%git clone https://github.com/golang/lint.git %GOPATH%\\src\\golang.org\\x\\lint

go build -o %GOPATH%\\bin\\gocode.exe github.com/mdempsky/gocode

%go build -o %GOPATH%\\bin\\gopkgs.exe github.com/uudashr/gopkgs/cmd/gopkgs%

%go build -o %GOPATH%\\bin\\go-outline.exe github.com/ramya-rao-a/go-outline%

%go build -o %GOPATH%\\bin\\go-symbols.exe github.com/acroca/go-symbols%

%go build -o %GOPATH%\\bin\\guru.exe golang.org/x/tools/cmd/guru%

%go build -o %GOPATH%\\bin\\gorename.exe golang.org/x/tools/cmd/gorename%

%go build -o %GOPATH%\\bin\\dlv.exe github.com/derekparker/delve/cmd/dlv%

go build -o %GOPATH%\\bin\\gocode-gomod.exe github.com/stamblerre/gocode

go build -o %GOPATH%\\bin\\godef.exe github.com/rogpeppe/godef

go build -o %GOPATH%\\bin\\godef-gomod.exe github.com/ianthehat/godef

%go build -o %GOPATH%\\bin\\goreturns.exe github.com/sqs/goreturns%

go build -o %GOPATH%\\bin\\golint.exe golang.org/x/lint/golint

pause

改名为run.bat,运行即可

另一种(还没运行)

@echo off

echo 正在运行

echo 下载tools等工具

git clone https://github.com/golang/tools.git C:/Users/Administrator/go/src/golang.org/x/tools

git clone https://github.com/golang/lint C:/Users/Administrator/go/src/golang.org/x/lint

git clone https://github.com/golang/net C:/Users/Administrator/go/src/golang.org/x/net

git clone https://github.com/golang/text C:/Users/Administrator/go/src/golang.org/x/text

git clone https://github.com/golang/crypto C:/Users/Administrator/go/src/golang.org/x/crypto

git clone https://github.com/golang/sys C:/Users/Administrator/go/src/golang.org/x/sys

git clone https://github.com/ramya-rao-a/go-outline.git C:/Users/Administrator/go/src/github.com/ramya-rao-a/go-outline

git clone https://github.com/acroca/go-symbols.git C:/Users/Administrator/go/src/github.com/acroca/go-symbols

git clone https://github.com/rogpeppe/godef.git C:/Users/Administrator/go/src/github.com/rogpeppe/godef

git clone https://github.com/sqs/goreturns.git C:/Users/Administrator/go/src/github.com/sqs/goreturns

git clone https://github.com/cweill/gotests.git C:/Users/Administrator/go/src/github.com/cweill/gotests

git clone https://github.com/josharian/impl.git C:/Users/Administrator/go/src/github.com/josharian/impl

git clone https://github.com/golang/lint.git C:/Users/Administrator/go/src/github.com/golang/lint

git clone https://github.com/mdempsky/gocode.git C:/Users/Administrator/go/src/github.com/mdempsky/gocode

git clone https://github.com/uudashr/gopkgs.git C:/Users/Administrator/go/src/github.com/uudashr/gopkgs

git clone https://github.com/stamblerre/gocode.git C:/Users/Administrator/go/src/github.com/stamblerre/gocode

rem 64位操作系统用

REM  git clone  https://github.com/derekparker/delve.git  C:/Users/Administrator/go/src/github.com/derekparker/  

REM  git clone https://github.com/go-delve/delve.git C:/Users/Administrator/go/src/github.com/go-delve

cd "C:/Users/Administrator/go"

go install github.com/ramya-rao-a/go-outline

go install golang.org/x/tools/cmd/guru

go install golang.org/x/tools/cmd/gorename

go install github.com/acroca/go-symbols

go install github.com/rogpeppe/godef

go install github.com/sqs/goreturns

go install github.com/cweill/gotests/gotests

go install github.com/josharian/impl

go install github.com/golang/lint/golint

go install github.com/mdempsky/gocode

go install github.com/uudashr/gopkgs/cmd/gopkgs

go build -o C:\\Users\\Administrator\\go\\bin\\gocode-gomod.exe github.com/stamblerre/gocode

echo 当模块设置成GO111MODULE=on的时候

go install golang.org/x/tools/cmd/goimports

rem 64位操作系统用

REM go install github.com/derekparker/delve/cmd/dlv

REM go get -v -u  https://github.com/go-delve/delve/delve/cmd/dlv

 @cmd.exe

pause

三、在visual studio code下配置

ctrl+shift+p搜索以下插件

go    //go插件

Chinese (Simplified) Language Pack for Visual Studio Code    //中文版

Code Runner

打开GOPATH文件夹:

ctrl+shift+p搜索settings.json

"go.buildOnSave": "workspace",

    "go.lintOnSave": "package",

    "go.vetOnSave": "package",

    "go.buildTags": "",

    "go.buildFlags": [],

    "go.lintFlags": [],

    "go.vetFlags": [],

    "go.coverOnSave": false,

    "go.useCodeSnippetsOnFunctionSuggest": true,

    "go.formatTool": "goreturns",

    "go.goroot": "C:\\Go",

    "go.gopath": "D:\\gopath",

    "go.gocodeAutoBuild": false,

    "terminal.integrated.shell.windows": "C:\\windows\\System32\\cmd.exe",

    "go.autocompleteUnimportedPackages": true,

    "go.docsTool": "guru",

    "go.gocodePackageLookupMode": "go",

    "files.associations": {

        "*.tpl": "html"

    },

    "go.inferGopath": true,

相关文章

  • vscode配置go环境

    mac安装go环境 Go开发:Mac上安装Go环境和VS Code 插件安装 添加环境变量 添加插件目录: 打开v...

  • Go环境一站式搭建和hello world程序初探

    第一步:Go环境的安装 去Go安装包下载Go环境,本人是在windows下操作的,下载如下安装包。Go环境 下载好...

  • 开发自己的区块链基础功能篇

    准备工作: 安装go开发环境 用go搭建web服务 go语言基础 安装go开发环境 到https://golang...

  • golang 开发环境搭建

    配置 golang 开发环境,系统 archlinux。 安装 go 软件包 安装 vim-go 插件 安装 go...

  • Ubuntu从头搭建Hyperledger Fabric网络环境

    Ubuntu版本:18.04 一、安装go以及配置环境变量 安装go,选择版本1.14 环境配置 二、安装curl...

  • HDFS & Yarn 即Hadoop by Jmx on Pr

    一、安装Go环境 因为Promethues是用go语言开发,所以要先安装一个go环境 1、下载安装包地址: Lin...

  • go工程配置

    部署方法,步骤 下载go安装文件,安装go 将安装路径设置为 GOPATH环境变量 查看环境信息: GOBIN: ...

  • go 安装配置(一)

    基本 安装gobrew install go 查看go环境变量go ev 设置go环境变量vim .bash_pr...

  • GO 从入门开始放弃

    GO现在比较流行的游戏等服务器开发语言。 配置beego 插件: 下载安装go 环境因为go环境安装时,自动生成的...

  • 本地机器部署Go环境

    1、安装go的SDK 2、检查go环境,配置好相关的环境变量 查看环境变量: go path 查看某个环境变...

网友评论

      本文标题:Go环境的安装

      本文链接:https://www.haomeiwen.com/subject/uqyinctx.html