go get 之后 import 报错问题解决

执行 go get 之后,下载的内容会出现在pkg目录下,而不是src目录下,导致项目编译不通过,网上查了很久,把问题解决的过程记录如下:

1、在当前项目目录下,执行 go mod init 目录名称  指令:

D:\goproj\src\SweatSugarApi>go mod init SweatSugarApi
go: creating new go.mod: module SweatSugarApi

2.在开发环境中go build

错误: 进程退出代码 1.

C:/Program Files/Go/bin/go.exe build [D:/goproj/src/SweatSugarApi]

go: finding module for package github.com/satori/go.uuid

util\guid.go:14:2: module github.com/satori/go.uuid: Get "https://proxy.golang.org/github.com/satori/go.uuid/@v/list": dial tcp 172.217.160.113: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.

3.设置下载参数和下载地址,准备go get 下载

D:\goproj\src\SweatSugarApi>set GO111MODULE=on

D:\goproj\src\SweatSugarApi>set GOPROXY=https://goproxy.io

4.执行go get命令,带@master版本号

D:\goproj\src\SweatSugarApi>go get github.com/satori/go.uuid/@master
go: downloading github.com/satori/go.uuid v1.2.1-0.20181028125025-b2ce2384e17b
go: github.com/satori/go.uuid master => v1.2.1-0.20181028125025-b2ce2384e17b

5.编译通过

感谢:https://zhuanlan.zhihu.com/p/59687626

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值