首页 > 其他分享 >go mod: 配置代理

go mod: 配置代理

时间:2024-11-16 12:43:16浏览次数:1  
标签:downloading 代理 github go mattn com added mod

一,安装第三方库时报错:

没添加代理时,会报错超时错误

# go get -u github.com/gofiber/fiber/v2
go: module github.com/gofiber/fiber/v2: Get "https://proxy.golang.org/github.com/gofiber/fiber/v2/@v/list": 
   dial tcp 142.250.217.81:443: i/o timeout

 

二,解决:

编辑/etc/profile

# vi /etc/profile

添加内容:

export GO111MODULE=on
export GOPROXY=https://goproxy.cn

使生效:

# source /etc/profile

查看效果:

# go env
GO111MODULE='on'
GOARCH='amd64'
GOBIN=''
GOCACHE='/root/.cache/go-build'
GOENV='/root/.config/go/env'
GOEXE=''
GOEXPERIMENT=''
GOFLAGS=''
GOHOSTARCH='amd64'
GOHOSTOS='linux'
GOINSECURE=''
GOMODCACHE='/data/gopath/pkg/mod'
GONOPROXY=''
GONOSUMDB=''
GOOS='linux'
GOPATH='/data/gopath'
GOPRIVATE=''
GOPROXY='https://goproxy.cn'
...

三,再次安装第三方库时可以成功安装:

安装:

# go get -u github.com/gofiber/fiber/v2
go: downloading github.com/gofiber/fiber/v2 v2.52.5
go: downloading github.com/gofiber/fiber v1.14.6
go: downloading github.com/google/uuid v1.5.0
go: downloading github.com/mattn/go-colorable v0.1.13
go: downloading github.com/mattn/go-isatty v0.0.20
go: downloading github.com/mattn/go-runewidth v0.0.15
go: downloading github.com/google/uuid v1.6.0
go: downloading github.com/valyala/bytebufferpool v1.0.0
go: downloading github.com/mattn/go-runewidth v0.0.16
go: downloading github.com/valyala/fasthttp v1.51.0
go: downloading github.com/valyala/fasthttp v1.57.0
go: downloading golang.org/x/sys v0.15.0
go: downloading golang.org/x/sys v0.27.0
go: downloading github.com/rivo/uniseg v0.2.0
go: downloading github.com/rivo/uniseg v0.4.7
go: downloading github.com/andybalholm/brotli v1.0.5
go: downloading github.com/andybalholm/brotli v1.1.1
go: downloading github.com/klauspost/compress v1.17.0
go: downloading github.com/klauspost/compress v1.17.11
go: downloading github.com/valyala/tcplisten v1.0.0
go: added github.com/andybalholm/brotli v1.1.1
go: added github.com/gofiber/fiber/v2 v2.52.5
go: added github.com/google/uuid v1.6.0
go: added github.com/klauspost/compress v1.17.11
go: added github.com/mattn/go-colorable v0.1.13
go: added github.com/mattn/go-isatty v0.0.20
go: added github.com/mattn/go-runewidth v0.0.16
go: added github.com/rivo/uniseg v0.4.7
go: added github.com/valyala/bytebufferpool v1.0.0
go: added github.com/valyala/fasthttp v1.57.0
go: added github.com/valyala/tcplisten v1.0.0
go: added golang.org/x/sys v0.27.0

查看已安装模块:

# go list -m all
industry
github.com/andybalholm/brotli v1.1.1
github.com/gofiber/fiber/v2 v2.52.5
github.com/google/uuid v1.6.0
github.com/klauspost/compress v1.17.11
github.com/mattn/go-colorable v0.1.13
github.com/mattn/go-isatty v0.0.20
github.com/mattn/go-runewidth v0.0.16
github.com/philhofer/fwd v1.1.2
github.com/rivo/uniseg v0.4.7
github.com/tinylib/msgp v1.1.8
github.com/valyala/bytebufferpool v1.0.0
github.com/valyala/fasthttp v1.57.0
github.com/valyala/tcplisten v1.0.0
github.com/xyproto/randomstring v1.0.5
golang.org/x/crypto v0.28.0
golang.org/x/net v0.30.0
golang.org/x/sys v0.27.0
golang.org/x/text v0.19.0

 

标签:downloading,代理,github,go,mattn,com,added,mod
From: https://www.cnblogs.com/architectforest/p/18545499

相关文章

  • 川土微一级代理商|CA-IS3722HS、CA-IS3721HS、CA-IS3720HS
    川土微标准数字隔离器、电表专用数字隔离器、集成隔离电源的标准数字隔离器、隔离I2C、隔离CAN、带隔离电源的隔离CAN、隔离RS-485/422、带隔离电源的隔离RS-485/422、低成本隔离RS-485/422、0.5W全集成隔离电源、全差分隔离运放、隔离误差运放等。2通道数字隔离产品包含:CA‐IS37......
  • go fiber:全局中间件添加排除的path
    一,代码:全局中间件对所有的api生效,如果有个别不想应用全局中间件的api,则需要从代码中进行排除:例如:支付宝或微信的回调接口packagemiddlewareimport( "fmt" "github.com/gofiber/fiber/v2""regexp")funcApiSign(c*fiber.Ctx)error{//得到当前url ......
  • go fiber: 把异常信息写到错误日志中
    一,代码:1,userBusiness.gopackagebusinessimport("fmt")//得到多个用户,按分页返回funcGetUserList(pageint,pageSizeint)(string,error){b:=0a:=100/bfmt.Println(a)return"1,2,3",nil}代码中包含有除0错,会引发panic2,userControlle......
  • golang: 在线上用nginx部署应用
    一,启动应用:1,编译程序$gobuild2,用nohup启动应用的二进制程序$nohup/data/goapp/industry/industry>>/data/logs/gologs/back.log2>&1&[1]48963,检查应用是否启动:$ss-lntp|grep3000LISTEN040960.0.0.0:30000.0.0.0:*users:(("......
  • go fiber: 增加访问日志accesslog
    一,代码这里我们使用官方提供的github.com/gofiber/fiber/v2/middleware/logger这个现成的中间件官方文档地址:https://docs.gofiber.io/api/middleware/logger/routes.gopackageroutesimport( "github.com/gofiber/fiber/v2" "github.com/gofiber/fiber/v2/middleware/......
  • go fiber: 多个全局中间件的执行顺序
    一,代码:middleware.gopackagemiddlewareimport( "fmt" "github.com/gofiber/fiber/v2")funcMiddle1(c*fiber.Ctx)error{ fmt.Println("middle1before") err:=c.Next() fmt.Println("middle1after") returnerr}......
  • go fiber:路由中间件
    一,目录结构:二,代码1,中间件代码packagemiddlewareimport( "fmt" "github.com/gofiber/fiber/v2" "industry/config")//token校验funcCheckUser(c*fiber.Ctx)error{ token:=c.Query("token") fmt.Println("token:"......
  • django naive datetime问题
    naivedatetime问题,其实就是datetime数据没有携带时间就传递给了模型类现象:D:\anaconda3\envs\schedule_devops\lib\site-packages\django\db\models\fields_init_.py:1367:RuntimeWarning:DateTimeFieldNodeStopRecord.stop_timereceivedanaivedatetime(2024-11-1602:......
  • Let'sGoFurther - Chapter 6: SQL Migrations
      InstallingthemigratetoolTomanageSQLmigrationsinthisprojectwe’regoingtousethemigratecommand-line tool(whichitselfiswritteninGo).OnLinuxandWindows,theeasiestmethodistodownloadapre-builtbinaryandmove ittoalocat......
  • 通过MongoDB Atlas 实现语义搜索与 RAG——迈向AI的搜索机制
    目录通过MongoDBAtlas实现语义搜索与RAG——迈向AI的搜索机制一、引言二、语义搜索与MongoDBAtlas的背景三、MongoDBAtlas的向量搜索功能1.向量搜索的实现方式2.典型操作示例四、RAG在MongoDBAtlas的应用1、RAG是什么2、RAG的实现过程3、RAG的实际应......