登录
首页 >  Golang >  Go问答

列举模块的依赖关系,而非包的依赖关系

来源:stackoverflow

时间:2024-03-14 20:39:27 368浏览 收藏

IT行业相对于一般传统行业,发展更新速度更快,一旦停止了学习,很快就会被行业所淘汰。所以我们需要踏踏实实的不断学习,精进自己的技术,尤其是初学者。今天golang学习网给大家整理了《列举模块的依赖关系,而非包的依赖关系》,聊聊,我们一起来看看吧!

问题内容

如果我有这个文件:

package main
import "github.com/dinedal/textql/storage"

我可以使用以下之一列出依赖项:

go list -deps
go mod graph

但是如果我有这个文件:

package main
import "github.com/dinedal/textql"

未列出所有依赖项。例如查看 mod 文件, 现在没有列出 require 下的任何软件包。最后我尝试了这个 有趣的结果:

PS C:\> go list -deps github.com/dinedal/textql
go: finding module for package github.com/dinedal/textql
module github.com/dinedal/textql@latest found
(v0.0.0-20200608170856-250cf763f52c), but does not contain package
github.com/dinedal/textql

解决方案


根据评论,我能够获取模块的依赖项列表 像这样:

go mod init deps
go get github.com/dinedal/textql
go list -deps github.com/dinedal/textql/...

此命令也可用于测试,因为它会清除模块缓存:

go clean -modcache

本篇关于《列举模块的依赖关系,而非包的依赖关系》的介绍就到此结束啦,但是学无止境,想要了解学习更多关于Golang的相关知识,请关注golang学习网公众号!

声明:本文转载于:stackoverflow 如有侵犯,请联系study_golang@163.com删除
相关阅读
更多>
最新阅读
更多>
课程推荐
更多>