Golang 的子命令

目录

Go 的全部子命令

运行 go,就可以看到 go 的所有子命令:

$ go
Go is a tool for managing Go source code.

Usage:
    
    go command [arguments]
    
The commands are:
    
    build       compile packages and dependencies
    clean       remove object files
    doc         show documentation for package or symbol
    env         print Go environment information
    fix         run go tool fix on packages
    fmt         run gofmt on 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
    run         compile and run Go program
    test        test packages
    tool        run specified go tool
    version     print Go version
    vet         run go tool vet on packages
    
Use "go help [command]" for more information about a command.

其中go tool 进一步包含了其它子命令:

$ go tool
addr2line
api
asm
cgo
compile
cover
dist
doc
fix
link
nm
objdump
pack
pprof
trace
vet
yacc

Go’s ToolsCommand go 中介绍了这些子命令的用法。

go tool compile:编译器

generate

generate用来执行代码注释指定的命令:

//go:generate command argument...

command是任意指定的,通常用来对代码预先处理。go generate必须手动执行,go build等不会自动触发generate的运行。

查看依赖包引入原因:go mod why

go mod why 查看为什么会依赖 github.com/shirou/gopsutil:

 go mod why github.com/shirou/gopsutil 
XXX.XXX.XXX/x/xx/dal/db imports
        XXX.XXX.XXX/aweme-go/ktest/mock imports
        XXX.XXX.XXX/edu/memongo imports
        XXX.XXX.XXX/edu/memongo/mongobin imports
        github.com/spf13/afero imports
        io/fs: package io/fs is not in GOROOT (/Users/xx/Work/Bin/go-1.14.2/go/src/io/fs)
XXX.XXX.XXX/x/xx/dal/db imports
        XXX.XXX.XXX/aweme-go/ktest/mock imports
        XXX.XXX.XXX/edu/memongo imports
        XXX.XXX.XXX/edu/memongo/mongobin imports
        github.com/spf13/afero tested by
        github.com/spf13/afero.test imports
        testing/fstest: package testing/fstest is not in GOROOT (/Users/xx/Work/Bin/go-1.14.2/go/src/testing/fstest)

参考

  1. Command go

推荐阅读

赞助商广告

Copyright @2011-2019 All rights reserved. 转载请添加原文连接,合作请加微信lijiaocn或者发送邮件: [email protected],备注网站合作

友情链接:  李佶澳的博客  小鸟笔记  软件手册  编程手册  运营手册  爱马影视  网络课程  奇技淫巧  课程文档  精选文章  发现知识星球  百度搜索 谷歌搜索