athens server
参考配置
- 来自官方的配置图
athens serverathens serverGOPROXY
环境搭建
- docker-compose 文件
version: "3"
services:
nexus:
image: sonatype/nexus3:3.17.0
ports:
- "80:8081"
volumes:
- "./nexus-data:/nexus-data"
athens:
image: gomods/athens:latest
ports:
- "3000:3000"
- 配置go proxy
golang 代码使用proxy
- 配置host 文件
因为localhost 有问题,所以简单配置了一个127.0.0.1 dalongrong.com
127.0.0.1 dalongrong.com
- 简单go mod 项目
go mod init github.com/rongfengliang/nexus-mod
go: creating new go.mod: module github.com/rongfengliang/nexus-mod
- 一个简单的http server 代码
main.go:
package main
import (
"fmt"
"net/http"
"github.com/urfave/negroni"
)
func main() {
mux := http.NewServeMux()
mux.HandleFunc("/", func(w http.ResponseWriter, req *http.Request) {
fmt.Fprintf(w, "Welcome to the home page!")
})
n := negroni.Classic() // Includes some default middlewares
n.UseHandler(mux)
http.ListenAndServe(":8000", n)
}
- 配置GOPROXY
export GOPROXY=http://dalongrong.com/repository/golang/
- 添加缺少的依赖
go mod tidy
- 构建
go build
- 运行
./nexus-mod
效果
├── go.mod
├── go.sum
├── main.go
└── nexus-mod
- nexus 系统proxy 的信息
说明
以上是一个简单的学习试用,同时也支持group 类型的,还是很不错的
参考资料
https://help.sonatype.com/repomanager3/release-notes/2019-release-notes#id-2019ReleaseNotes-RepositoryManager3.17.0
https://help.sonatype.com/repomanager3/formats/go-repositories
https://github.com/rongfengliang/nexus-golang-package