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!吧

相关文章

什么是Go的接口? 接口可以说是一种类型,可以粗略的理解为他...
1、Golang指针 在介绍Golang指针隐式间接引用前,先简单说下...
1、概述 1.1 Protocol buffers定义 Protocol buffe...
判断文件是否存在,需要用到"os"包中的两个函数: os.Stat(...
1、编译环境 OS :Loongnix-Server Linux release 8.3 CPU指...
1、概述 Golang是一种强类型语言,虽然在代码中经常看到i:=1...