當我在 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所以這對我來說很神奇。
1 回答

滄海一幻覺
TA貢獻1824條經驗 獲得超5個贊
很簡單,看一下:
$> 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”的標簽中。
- 1 回答
- 0 關注
- 145 瀏覽
添加回答
舉報
0/150
提交
取消