go 项目启动失败

340 阅读1分钟

今天遇到两个问题

问题一

| ___ \
| |_/ /  ___   ___
| ___ \ / _ \ / _ \
| |_/ /|  __/|  __/
\____/  \___| \___| v1.10.0
2021/11/22 16:27:42 INFO0001 Using '360skbi' as 'appname'
2021/11/22 16:27:42 INFO0002 Initializing watcher...
build 360skbi: cannot load goutils/utils: malformed module path "goutils/utils": missing dot in first path element
2021/11/22 16:27:44 ERROR0003 Failed to build the application: build 360skbi: cannot load goutils/utils: malformed module path "goutils/utils": missing dot in first path element

原来是因为项目goutils 引入goutils/utils 问题,如果将goutils 作为第三方包引入的话,import 自己的包也要通过 github 原地址,如下代码

package databox

import (
   "github.com/codewangz/goutils/utils"
   "reflect"
   "strconv"
   "strings"
)

type dataBox struct {
   data interface{}
}

问题二,启动项目报 goproxy timeout,如下错误

| ___ \
| |_/ /  ___   ___
| ___ \ / _ \ / _ \
| |_/ /|  __/|  __/
\____/  \___| \___| v1.10.0
2021/11/22 17:54:23 INFO0001 Using '360skbi' as 'appname'
2021/11/22 17:54:23 INFO0002 Initializing watcher...
go: github.com/codewangz/goutils@v1.0.3: Get "https://proxy.golang.org/github.com/codewangz/goutils/@v/v1.0.3.mod": dial tcp 142.250.207.81:443: i/o timeout
go: downloading github.com/codewangz/goutils v1.0.3
go: github.com/codewangz/goutils@v1.0.3: Get "https://proxy.golang.org/github.com/codewangz/goutils/@v/v1.0.3.mod": dial tcp 142.250.207.81:443: i/o timeout

尝试拉取 go github.com/codewangz/goutils@v1.0.3 仍然失败。

解决问题 换GOPROXY

命令如下

go env -w GOPROXY=goproxy.cn,https://goproxy.io…

地址从我windows 环境复制的