Go:no required module provides package…to add it:…


记录一次Go编译报错

项目地址:

源码修改:

将项目根目录中frontend重命名为frontend-src:

在这里插入图片描述

编译报错:

$ go build -o frontend
server.go:25:2: no required module provides package github.com/apache/servicecomb-service-center/frontend/schema; to add it:
        go get github.com/apache/servicecomb-service-center/frontend/schema

在这里插入图片描述

根据报错提示尝试解决:

EB@DESKTOP-K45IA6V MINGW64 /d/workspace/sme/trunk/servicecomb/servicecomb-service-center-1.3.0/frontend-src
$ go get github.com/apache/servicecomb-service-center/frontend/schema
go get: module github.com/apache/servicecomb-service-center/frontend/schema: reading https://goproxy.io/github.com/apache/servicecomb-service-ce
nter/frontend/schema/@v/list: 404 Not Found
        server response: not found: github.com/apache/servicecomb-service-center/frontend/schema@latest: no matching versions for query "latest"

在这里插入图片描述

仍然报错。(因为确实没有这个module)

解决方法:

猛然想起,自己rename frontend to frontend-src,但是没有修改源码中的导入路径:

在这里插入图片描述

修改项目内部目录(包名、位置发生变化),也应当修改项目内部依赖此包的文件中对此包的导入路径:

rename

import “github.com/apache/servicecomb-service-center/frontend/schema”

to

import “github.com/apache/servicecomb-service-center/frontend-src/schema”

在这里插入图片描述