安装某个库的时候依赖于redis库,总是出现这样的错误:
go install
go: github.com/go-redis/redis/v7@v7.2.0: parsing go.mod: missing module line
猜测是redis库装错了,于是删除 C:Usersahfuzhanggosrcgithub.comgo-redis,然后删除:C:Usersahfuzhanggopkgmodcache目录下所有文件。
尝试单独安装redis库:
go get -u github.com/go-redis/redis
go get github.com/go-redis/redis: module github.com/go-redis/redis: invalid character '.' after top-level value
出现错误后,尝试修改环境变量:
set GO111MODULE=on
重试 go get -u github.com/go-redis/redis 仍然不行。