GolangNote

Golang笔记

用go list 列出项目中所有直接依赖库

Permalink

有时候需要列出当前项目中所有直接依赖库,跟 go.mod 里的内容稍有不同。

使用 go list 命令行,以本站的项目源码为例

Bash: go list
1
2
3
4
5
6
7
8
9
$ go list ./...
golangnote
golangnote/app
golangnote/approuter
golangnote/controller
golangnote/cronjob
golangnote/middleware
golangnote/model
golangnote/util

这会列出本地自定义的包

Bash:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
$ go list -m -f '{{if not .Indirect}}{{.Path}}{{end}}' all
golangnote
github.com/VictoriaMetrics/fastcache
github.com/alecthomas/chroma
github.com/boltdb/bolt
github.com/cespare/xxhash/v2
github.com/disintegration/imaging
github.com/ego008/captcha
github.com/ego008/goutils
github.com/ego008/sdb
github.com/ego008/youdb
github.com/fasthttp/router
github.com/gorilla/securecookie
github.com/json-iterator/go
github.com/mssola/user_agent
github.com/rs/xid
github.com/segmentio/fasthash
github.com/shurcooL/github_flavored_markdown
github.com/tidwall/gjson
github.com/valyala/fasthttp
github.com/valyala/quicktemplate
github.com/weint/config
golang.org/x/oauth2
google.golang.org/api

加上更多参数就得到想要的结果。

本文网址: https://golangnote.com/topic/281.html 转摘请注明来源

Related articles

Write a Comment to "用go list 列出项目中所有直接依赖库"

Submit Comment Login
Based on Golang + fastHTTP + sdb | go1.17.1 Processed in 0ms