golang自定义域名导包路径
golang自定义域名导包路径
今天看到gorm的导包地址go get -u gorm.io/gorm
,然后突然很好奇他是怎么实现的,所以研究了一下
访问view-source:https://gorm.io/gorm
看到如下代码
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width" />
<meta name="go-import" content="gorm.io/gorm git https://github.com/go-gorm/gorm">
<meta name="go-source" content="gorm.io/gorm https://github.com/go-gorm/gorm https://github.com/go-gorm/gorm/tree/master{/dir} https://github.com/go-gorm/gorm/blob/master{/dir}/{file}#L{line}">
<title>Gorm</title>
</head>
<body>
<a href="https://gorm.io">https://gorm.io</a>
</body>
</html>
感觉重点就在这些meta头上,搜了一下官方文档,找到
https://golang.google.cn/cmd/go/#hdr-Remote_import_paths
发现的确如此,域名地址需要https的,不然导包时候会有问题
Last modified on 2020-09-16