Go tools

目录

在命令行里输入 go 我们就可以看到go提供的工具:

$ go
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         download and install packages and dependencies
	install     compile and install packages and dependencies
	list        list packages or modules
	mod         module 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

go build

go build 是用来编译Go代码的,常见用法是:

$ go build
$ go build -o main

其中 -o main 是用来指定编译出来的可执行文件名。

go test

go test 是用来跑单元测试的,这个需要阅读这里:https://golang.org/pkg/testing/

go vet

go vet 是用来检验代码中常见错误的,用法为:

$ go vet ./...

go mod

go mod 是go官方的依赖管理工具,可以参考这里:https://jiajunhuang.com/articles/2018_09_03-go_module.md.html


  • 上一篇:并发编程
  • 下一篇:恭喜你已经完成了 Go语言简明教程

更多文章
  • Go语言性能优化实战
  • 那些年开发的时候踩过的坑
  • (关系型)数据库优化总结
  • 动态规划民科教程
  • Golang 分布式异步任务队列 Machinery 教程
  • 使用geohash完成地理距离计算
  • 2018年就要到了,这一年都做了什么呢?
  • 算法导论阅读笔记 --- 排序算法
  • 短链系统的实现
  • Git HTTPS 如何保存密码
  • 程序员修炼之道 阅读笔记
  • Python开发实践经验
  • Golang实现平滑重启(优雅重启)
  • traefik 教程
  • Web开发系列(十):事务和锁