如何知道从哪里获取软件包

Den*_*nge 0 go go-modules

当我在go应用程序中导入软件包时(使用带有golang插件的模块和vscode):

import (
   cors "goa.design/plugins/cors/dsl"
)
Run Code Online (Sandbox Code Playgroud)

go自动检索包。怎么知道从哪里得到它?我想它简单地从github.com来源,但该项目的存储库是https://github.com/goadesign/goa没有.的名称。如果我将导入更改为:

import (
   cors "goa.design/plugins/v3/cors/dsl"
)
Run Code Online (Sandbox Code Playgroud)

它检索v3包。我很乐意使用RTFM,但不确定我需要阅读哪个FM。

顺便说一句:这是我的第二天,go所以这对我来说是神奇的。

Зел*_*ный 7

很简单,检查一下:

$> curl https://goa.design/plugins/cors/dsl
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en-us">
<head>
  <meta http-equiv="content-type" content="text/html; charset=utf-8">


  <meta name="go-import" content="goa.design/plugins git https://github.com/goadesign/plugins">
  <meta name="go-source" content="goa.design/plugins _ https://github.com/goadesign/plugins/tree/master/{/dir} https://github.com/goadesign/plugins/blob/master{/dir}/{file}#L{line}">
Run Code Online (Sandbox Code Playgroud)

此处的密钥位于名为“ go-import”的标签中。当go get请求https://goa.design/ ...时,它将命中该HTML文件并知道必须使用git从https://github.com/goadesign/plugins检索“ goa.design / ....” 。

这是一篇好文章