Skip to content

Instantly share code, notes, and snippets.

@fire9
Last active January 31, 2020 18:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save fire9/077090879d31eb8c8841f86edd3d6ba6 to your computer and use it in GitHub Desktop.
Save fire9/077090879d31eb8c8841f86edd3d6ba6 to your computer and use it in GitHub Desktop.

Go编程学习

配置Golang开发环境

环境变量设置

mkdir -p ~/Go/{bin,pkg,src}
# go environment
export GOPATH=$HOME/Go
export PATH=$GOBIN:$PATH
export GOBIN=$GOPATH/bin
export GOROOT=/usr/local/opt/go/libexec

安装相关库

go get -u -v github.com/rogpeppe/godef
go get -u -v github.com/jstemmer/gotags
go get -u -v golang.org/x/tools/cmd/goimports
go get -u -v github.com/zmb3/gogetdoc
go get -u -v github.com/golang/lint/golint
go get -u -v github.com/lukehoban/go-outline
go get -u -v sourcegraph.com/sqs/goreturns
go get -u -v golang.org/x/tools/cmd/gorename
go get -u -v github.com/tpng/gopkgs
go get -u -v github.com/newhook/go-symbols
go get -u -v golang.org/x/tools/cmd/guru
go get -u -v github.com/cweill/gotests
go get -u -v golang.org/x/tools/cmd/godoc
go get -u -v github.com/fatih/gomodifytags
go get -u -v github.com/derekparker/delve/cmd/dlv
go get -u -v github.com/kisielk/errcheck
go get -u -v github.com/alecthomas/gometalinter
go get -u -v github.com/klauspost/asmfmt/cmd/asmfmt
go get -u -v github.com/fatih/motion
go get -u -v github.com/zmb3/gogetdoc
go get -u -v github.com/josharian/impl
go get -u -v github.com/dominikh/go-tools/cmd/keyify
go get -u -v github.com/nsf/gocode
go get -u -v golang.org/x/tools/cmd/guru
go get -u -v github.com/jgautheron/goconst/cmd/goconst
go get -u -v github.com/jgautheron/usedexports
go get -u -v github.com/gordonklaus/ineffassign
go get -u -v golang.org/x/tools/cmd/oracle
go get -u -v golang.org/x/tools/cmd/vet

vscode go 插件配置:

"cmd+shift+p": “go:install/update tools” 安装插件, 全部选择 "go.toolsGopath": “指定tools包的路径,不指定默认在 GOPATH”

{
    "go.gopath": "${workspaceFolder}",
    "go.inferGopath": true,
    "go.autocompleteUnimportedPackages": true,
    "go.gocodePackageLookupMode": "go",
    "go.gotoSymbol.includeImports": true,
    "go.useCodeSnippetsOnFunctionSuggest": true,
    "go.useCodeSnippetsOnFunctionSuggestWithoutType": true,
    "go.docsTool": "gogetdoc"
}

Go 命令

  • go get
  • go run
  • go build
  • go fmt
  • go install
  • go test
  • go doc

变量声明:

var a intvar a, b int = 1, 2
var a, b, c = 1, "go", true
a, b, c := 1, "go", true
var (
    a = 1
    b = "go"
    c = true
)
// :=只能在函数内使用,不能用在函数外

Golang 学习整理

Go 零基础编程入门教程

Go 零基础编程入门教程 视频教程

Go 零基础编程入门教程 源代码下载

Go语言高级编程(Advanced Go Programming)

tutorialspoint go

Go 夜读

Go 夜读 视频

Go cheatsheet

GoLang 社区

GoCN

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment