doubu1950 2016-05-11 19:56
浏览 20
已采纳

直接从网域(例如goji)汇入套件

I noticed while importing packages from goji - it is hosted directly off their domain e.g:

package web

import (
    "goji.io"
)

func Start() {
    mux := goji.NewMux()
}

How are the packages being requested by go and how is it hosted in this way? I can't find any documentation, so I'm thinking it might be a neat trick.

  • 写回答

1条回答 默认 最新

  • dongshie8450 2016-05-11 20:15
    关注

    It's documented in the go command, under Remote Import Paths.

    If the import path is not a known code hosting site and also lacks a version control qualifier, the go tool attempts to fetch the import over https/http and looks for a tag in the document's HTML .

    The meta tag has the form:

    <meta name="go-import" content="import-prefix vcs repo-root"> 
    

    The import-prefix is the import path corresponding to the repository root. It must be a prefix or an exact match of the package being fetched with "go get". If it's not an exact match, another http request is made at the prefix to verify the tags match.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 python验证码滑块图像识别
  • ¥15 根据背景及设计要求撰写设计报告
  • ¥15 QT6颜色选择对话框显示不完整
  • ¥20 能提供一下思路或者代码吗
  • ¥15 用twincat控制!
  • ¥15 请问一下这个运行结果是怎么来的
  • ¥15 单通道放大电路的工作原理
  • ¥30 YOLO检测微调结果p为1
  • ¥15 DS18B20内部ADC模数转换器
  • ¥15 做个有关计算的小程序