this vim config is success !
出现这个说明安装成功了
[root@localhost lexVIm]# vim a.go
vim IDE的常用功能
第一个go程序
[root@golang code]# cat example.go
package main
import "fmt"
func main() {
fmt.Println("hello world")
}
#直接运行
[root@golang code]# go run example.go
hello world
# 先编译再执行
[root@golang code]# go build example.go
[root@golang code]# ls
example example.go
[root@golang code]# ./example
hello world
go的常用命令
查看go的帮助文档, --help
[root@localhost tmp]# go --help
Go is a tool for managing Go source code.
Usage:
go <command> [arguments]
The commands are:
bug start a bug report
build compile packages and dependencies
clean remove object files and cached files
doc show documentation for package or symbol
env print Go environment information
fix update packages to use new APIs
fmt gofmt (reformat) package sources
generate generate Go files by processing source
get add dependencies to current module and install them
install compile and install packages and dependencies
list list packages or modules
mod module maintenance
work workspace maintenance
run compile and run Go program
test test packages
tool run specified go tool
version print Go version
vet report likely mistakes in packages
问题(gd 不能跳转源码)
解决:配置安装源
1. 设置module管理模式
go env -w GO111MODULE=on
2.设置下载源
go env -w GOPROXY=https://goproxy.cn
3.下载guru
[root@golang code]# go get golang.org/x/tools/cmd/guru
go: go.mod file not found in current directory or any parent directory.
'go get' is no longer supported outside a module.
To build and install a command, use 'go install' with a version,
like 'go install example.com/cmd@latest'
For more information, see https://golang.org/doc/go-get-install-deprecation
or run 'go help get' or 'go help install'.
[root@golang code]# go mod init mycode
go: creating new go.mod: module mycode
go: to add module requirements and sums:
go mod tidy
[root@golang code]# ls
example example.go go.mod pkg
[root@golang code]# go get golang.org/x/tools/cmd/guru
$GOPATH/go.mod exists but should not
[root@golang code]# rm -rf go.mod
[root@golang code]# mkdir test
[root@golang code]# cd test
[root@golang test]# ls
[root@golang test]# pwd
/root/code/test
[root@golang test]# go mod init mycode
go: creating new go.mod: module mycode
[root@golang test]# ls
go.mod
[root@golang test]# go get golang.org/x/tools/cmd/guru
go: downloading golang.org/x/tools v0.12.0
go: downloading golang.org/x/sys v0.11.0
go: downloading golang.org/x/mod v0.12.0
go: added golang.org/x/mod v0.12.0
go: added golang.org/x/sys v0.11.0
go: added golang.org/x/tools v0.12.0
[root@golang test]# go build golang.org/x/tools/cmd/guru
[root@golang test]# mv guru $(go env GOROOT)/bin
[root@golang test]#
# 做完以上操作就可以正常跳转源码了
测试工具安装
安装curl
[root@localhost tmp]# yum install curl -y