Go语言的zerolog的问题

安装zerolog库的命令行如下:

go get -u github.com/rs/zerolog/log

运行结果如下:

go get: module github.com/rs/zerolog/log: Get "https://proxy.golang.org/github.com/rs/zerolog/log/@v/list": dial tcp 142.251.43.17:443: connectex: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond.

输入命令行如下:

$env:GOPROXY="https://proxy.golang.com.cn,direct"

再次安装zerolog库的运行结果如下:

go get github.com/rs/zerolog/log: github.com/rs/zerolog@v1.26.1: verifying module: github.com/rs/zerolog@v1.26.1: checking tree#9452087 against tree#9588719: Get "https://proxy.golang.com.cn/sumdb/sum.golang.org/tile/8/0/x036/922": read tcp 192.168.0.197:59917->124.14.21.12:443: wsarecv: An existing connection was forcibly closed by the remote host.

输入代码如下:

package main

import (
	"github.com/rs/zerolog"
	"github.com/rs/zerolog/log"
)

func main() {
	zerolog.TimeFieldFormat = zerolog.TimeFormatUnix
	log.Print("Hey! I'm a log message!")
}

运行结果如下:

main.go:4:2: no required module provides package github.com/rs/zerolog: go.mod file not found in current directory or any parent directory; see 'go help modules'
main.go:5:2: no required module provides package github.com/rs/zerolog/log: go.mod file not found in current directory or any parent directory; see 'go help modules'

来源于了解如何在 Go 中记录 - Learn | Microsoft Docs

了解如何在Go中记录。 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值