dqyz48470 2018-05-29 16:14
浏览 76

如何获取Go依赖者列表

Short of building a dependency graph, is there an existing way to retrieve a list of dependent packages given a target package?

Sourcegraph has a badge (shield) that shows you how many packages use a specific package but when I click their link to go to their UI, I cannot find a count or list of packages. Here's more info:

Example badge:

Sourcegraph

GitHub has a dependency graph but it doesn't appear to list packages for Go and its docs only mention JavaScript and Ruby per the following:

  • 写回答

1条回答 默认 最新

  • dswu26846 2018-05-29 16:32
    关注

    go list can do this for you, with use of the -f flag.

    go list -f '{{.Imports}}' ./...
    

    Will show a list of all imports for the current and child directories. You can pipe this through sort -u, for example, to get a list of all dependencies, or do other standard shell-based massaging. Consult the documentation for all of the formatting options available.

    If you need a recursive list, this is also possible with some shell scripting, by then using doing the same thing recursively on the output of the above command.

    评论

报告相同问题?

悬赏问题

  • ¥15 划分vlan后不通了
  • ¥15 GDI处理通道视频时总是带有白色锯齿
  • ¥20 用雷电模拟器安装百达屋apk一直闪退
  • ¥15 算能科技20240506咨询(拒绝大模型回答)
  • ¥15 自适应 AR 模型 参数估计Matlab程序
  • ¥100 角动量包络面如何用MATLAB绘制
  • ¥15 merge函数占用内存过大
  • ¥15 使用EMD去噪处理RML2016数据集时候的原理
  • ¥15 神经网络预测均方误差很小 但是图像上看着差别太大
  • ¥15 单片机无法进入HAL_TIM_PWM_PulseFinishedCallback回调函数