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

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


Record a Go compilation error

project address:

https://github.com/apache/servicecomb-service-center

Source code modification:

Rename frontend in the project root directory to frontend-src:

Insert image description here

Compilation error:

$ 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

Insert image description here

Try to solve the problem according to the error message:

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"

Insert image description here

Still getting error. (Because there is indeed no such module)

Solution:

Suddenly I remembered that I renamed frontend to frontend-src, but did not modify the import path in the source code:

Insert image description here

When modifying the internal directory of the project (the package name and location change), you should also modify the import path for this package in the files that depend on this package within the project :

rename

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

to

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

Insert image description here

Guess you like

Origin blog.csdn.net/test1280/article/details/119735741