VSCode Golang 环境搭建 (mac os)

前端之家收集整理的这篇文章主要介绍了VSCode Golang 环境搭建 (mac os)前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
  1. 安装Golang (略)
  2. 安装VS Code (略)
  3. 设置环境变量(source ~/.bash_profile)
export GOROOT='/usr/local/go'
export GOARCH='amd64'
export GOOS='darwin'
export GOPATH='/Users/your_name/gopath'
export PATH='/bin:/sbin:/usr/bin:/usr/local/bin:/usr/local/go/bin'

4. VSCode 安装扩展(略)

5. 执行如下脚本 (执行脚本前,就确保环境变量生效 source ~/.bash_profile)

#!/bin/bash

BASEDIR="$GOPATH/src/golang.org/x"

echo "BASEDIR >> $BASEDIR"

if [ ! -d $BASEDIR ];then
        mkdir -p $BASEDIR
        echo "create $BASEDIR"
fi

cd $BASEDIR
if [ ! -d "$BASEDIR/tools" ];then
        git clone https://github.com/golang/tools
else
        cd $BASEDIR/tools
        git pull
fi

go install golang.org/x/tools/cmd/guru
go install golang.org/x/tools/cmd/guru/serial
go install golang.org/x/tools/cmd/gorename
go install golang.org/x/tools/cmd/goimports
go install golang.org/x/tools/go/loader
go install golang.org/x/tools/go/buildutil
go install golang.org/x/tools/go/ast/astutil
go install golang.org/x/tools/go/gcexportdata
go install golang.org/x/tools/go/gcimporter15
go install golang.org/x/tools/go/ast/astutil
go install golang.org/x/tools/go/types/typeutil
go install golang.org/x/tools/refactor/satisfy
go install golang.org/x/tools/refactor/rename
go install golang.org/x/tools/refactor/importgraph
go install golang.org/x/tools/imports


go get -v github.com/nsf/gocode
go get -v github.com/rogpeppe/godef
go get -v github.com/golang/lint/golint
go get -v github.com/lukehoban/go-outline
go get -v sourcegraph.com/sqs/goreturns
go get -v golang.org/x/tools/cmd/gorename
go get -v github.com/tpng/gopkgs
go get -v github.com/newhook/go-symbols
go get -v golang.org/x/tools/cmd/guru

6. 打开VSCode,开始 Go!Go!Go!吧

原文链接:https://www.f2er.com/go/187774.html

猜你在找的Go相关文章