如何列出安装的软件包 [英] How to list installed go packages

查看:137
本文介绍了如何列出安装的软件包的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

据我所知 go distribution 带有某种包管理器。在之后去1.4.1 安装我已经运行了 go help 以便找到任何能够本地列出的子命令安装了 go packages ,但遗憾的是没有。



那怎么办? b

解决方案

goinstall 现在是历史记录



goinstall 被替换为 go get go get 用于管理外部/第三方库(例如下载它们,更新它们,安装它们等)。

键入 go help获取以查看命令行帮助,或者查看这些页面:

Command go



关于go命令 (博客文章)



如果您想列出已安装的软件包,可以使用 go list 命令执行此操作:



h2>

要在工作区中列出软件包,请转至工作区文件夹并运行以下命令:

  go list。/ ... 

./ 告诉从当前文件夹开始, ... 告诉递归下去。当然,这可以在任何其他文件夹中使用,而不仅仅是在您的工作区中(但通常这就是您感兴趣的内容)。

列出所有软件包



执行

 去列表... 

列出所有软件包,包括标准库的软件包,其次是外部库。



包和它们的依赖关系



如果你还想看到每个包所导入的包,你可以试试这个自定义格式:

  go list -f{{.ImportPath}} {{.Imports}}。/ ... 

-f 指定列表的替代格式,使用包 模板 。可以通过 go帮助列表命令打印其可以引用字段的结构。



如果您想查看所有依赖递归地(递归地依赖于导入的包),您可以使用这个自定义格式:

  go list -f{{.ImportPath}} {{.Deps}}。/ ... 



<但通常这是一个很长的列表,并且每个包的单个导入(>)就是您想要的。


To my knowledge go distribution comes with some sort of package manager. After go 1.4.1 installation I've run go help in order to find any sub-command capable of listing locally installed go packages, but unfortunately got none.

So how to do it?

解决方案

goinstall is now history

goinstall was replaced by go get. go get is used to manage external / 3rd party libraries (e.g. to download them, update them, install them etc).

Type go help get to see command line help, or check out these pages:

Command go

About the go command (blog post)

If you want to list installed packages, you can do that with the go list command:

Listing Packages

To list packages in your workspace, go to your workspace folder and run this command:

go list ./...

./ tells to start from the current folder, ... tells to go down recursively. Of course this works in any other folders not just in your go workspace (but usually that is what you're interested in).

List All Packages

Executing

go list ...

in any folder lists all the packages, including packages of the standard library first followed by external libraries in your go workspace.

Packages and their Dependencies

If you also want to see the imported packages by each package, you can try this custom format:

go list -f "{{.ImportPath}} {{.Imports}}" ./...

-f specifies an alternate format for the list, using the syntax of package template. The struct whose fields can be referenced can be printed by the go help list command.

If you want to see all the dependencies recursively (dependencies of imported packages recursively), you can use this custom format:

go list -f "{{.ImportPath}} {{.Deps}}" ./...

But usually this is a long list and just the single imports ("{{.Imports}}") of each package is what you want.

这篇关于如何列出安装的软件包的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆