猿问

go 如何知道从哪里获取包

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

import (
   cors "goa.design/plugins/cors/dsl")

go 自动检索包。go 如何知道从哪里得到它?我认为它只是从 github.com 中提取源代码,但该项目的存储库名称中https://github.com/goadesign/goa没有。.如果我将导入更改为:

import (
   cors "goa.design/plugins/v3/cors/dsl")

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

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


炎炎设计
浏览 122回答 1
1回答

沧海一幻觉

很简单,看一下:$> curl https://goa.design/plugins/cors/dsl<!DOCTYPE html><html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en"><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}">这里的关键在名为“go-import”的标签中。
随时随地看视频慕课网APP

相关分类

Go
我要回答