go 语言私有库搭建说明-athens

一、使用athens

说明代码仓库可以用gogs其他的都可以,但必需是域名和https访问 域名和https的配置自己百度,下面直接说athens的配置

athens的官网:https://docs.gomods.io/zh/

# pwd
# /home/test
# git clone https://github.com/gomods/athens.git
# cd athens
# make build-ver VERSION="0.2.0" 这命令在编辑的时候出了点问题,换成了下面的方式
# cd cmd/proxy
# go install
如果代理上有问题,可以切换到阿里云,不喜欢用命令用goland IDE也要以。
 
重点:在配置FilterFile的时候,是单独的一个文件中写 例:
    FilterFile = "e:/athens/filter.toml"
FileterFile
  athens约定的软件包过滤策略,当前可用策略包括D、-、+三种。D必须存在且放在第一行;-表示禁止下载此软件包,若请求,报403;+表示不从指定的GlobalEndpoint下载,而直接从域名指定的仓库获取软件包。-与+对软件包的策略可指定至版本,多个版本用,号分隔,甚至可使用版本修饰符(~, ^, >)。此外#开头的行表示注释,会被忽略。

D
# 内网的gitlab不需要通过GlobalEndpoint下载
+ git.example.com
+ github.com/gomods/athens v0.1,v0.2,v0.4.1

启动:
./athens -config_file=./config.dev.toml 然后就可以把go的proxy设置成 例:http://192.168.0.2 
其他的配置见官方说明

二、除了athens外也有其他的方式

jfrog artifactory。 

也可以用github上面的一些第三方包也可能 ,例:

package main

import (
	"net/http"

	"github.com/goproxy/goproxy"
)

func main() {
	http.ListenAndServe("localhost:8080", goproxy.New())
}

这才是我们所说的极其简单的方式,不是吗?

此外,Goproxy 现在支持多种存储方式:

磁盘:cacher.Disk
MinIO:cacher.MinIO
谷歌云存储:cacher.GCS
亚马逊简易存储服务:cacher.S3
微软 Azure Blob 存储:cacher.MABS
DigitalOcean Spaces:cacher.DOS
阿里云对象存储服务:cacher.OSS
七牛云 Kodo:cacher.Kodo

本文参考:

https://aofeisheng.com/posts/2019-06-06-you-may-not-need-to-use-athens-but-instead-use-goproxy

https://www.cnblogs.com/laud/p/athens.html  

猜你喜欢

转载自blog.csdn.net/oqzuser12345678999q/article/details/107309572