admin管理员组文章数量:1024681
VS code gives the following error when I use replace
in go.mod
:
could not import github/ilKhr/protos (no required module provides package ‘github/ilKhr/protos’)
project directory structure
/protos
|-gen
| |-go
| | |-sso
| | | |-sso.pb.go <-- package ssov1
| | | |-sso_grpc.pb.go <-- package ssov1
...
|-go.mod
|-go.sum
|-Taskfile.yaml
/sso
|-go.mod
|-...
/protos/go.mod
module github/ilKhr/protos
go 1.23.0
/sso/go.mod
module github/ilkhr/sso
go 1.23.0
require github/ilKhr/protos v0.0.0-unpublished
replace github/ilKhr/protos v0.0.0-unpublished => ../protos
server.go
package auth
import ssov1 "github/ilKhr/protos" // <- could not import github/ilKhr/protos (no required module provides package "github/ilKhr/protos")
VS code gives the following error when I use replace
in go.mod
:
could not import github/ilKhr/protos (no required module provides package ‘github/ilKhr/protos’)
project directory structure
/protos
|-gen
| |-go
| | |-sso
| | | |-sso.pb.go <-- package ssov1
| | | |-sso_grpc.pb.go <-- package ssov1
...
|-go.mod
|-go.sum
|-Taskfile.yaml
/sso
|-go.mod
|-...
/protos/go.mod
module github/ilKhr/protos
go 1.23.0
/sso/go.mod
module github/ilkhr/sso
go 1.23.0
require github/ilKhr/protos v0.0.0-unpublished
replace github/ilKhr/protos v0.0.0-unpublished => ../protos
server.go
package auth
import ssov1 "github/ilKhr/protos" // <- could not import github/ilKhr/protos (no required module provides package "github/ilKhr/protos")
Share
Improve this question
asked Nov 18, 2024 at 14:12
Илья ХоришкоИлья Хоришко
1,2251 gold badge11 silver badges22 bronze badges
1 Answer
Reset to default -1The thing is that when I imported ssov1
incorrectly.
The correct import, it should be done manually, VS Code didn't do it automatically for me
I.e. literally you need to write import to the directory where Go files are located (see project structure).
server.go
package auth
import ssov1 "github/ilKhr/protos/gen/go/sso"
VS code gives the following error when I use replace
in go.mod
:
could not import github/ilKhr/protos (no required module provides package ‘github/ilKhr/protos’)
project directory structure
/protos
|-gen
| |-go
| | |-sso
| | | |-sso.pb.go <-- package ssov1
| | | |-sso_grpc.pb.go <-- package ssov1
...
|-go.mod
|-go.sum
|-Taskfile.yaml
/sso
|-go.mod
|-...
/protos/go.mod
module github/ilKhr/protos
go 1.23.0
/sso/go.mod
module github/ilkhr/sso
go 1.23.0
require github/ilKhr/protos v0.0.0-unpublished
replace github/ilKhr/protos v0.0.0-unpublished => ../protos
server.go
package auth
import ssov1 "github/ilKhr/protos" // <- could not import github/ilKhr/protos (no required module provides package "github/ilKhr/protos")
VS code gives the following error when I use replace
in go.mod
:
could not import github/ilKhr/protos (no required module provides package ‘github/ilKhr/protos’)
project directory structure
/protos
|-gen
| |-go
| | |-sso
| | | |-sso.pb.go <-- package ssov1
| | | |-sso_grpc.pb.go <-- package ssov1
...
|-go.mod
|-go.sum
|-Taskfile.yaml
/sso
|-go.mod
|-...
/protos/go.mod
module github/ilKhr/protos
go 1.23.0
/sso/go.mod
module github/ilkhr/sso
go 1.23.0
require github/ilKhr/protos v0.0.0-unpublished
replace github/ilKhr/protos v0.0.0-unpublished => ../protos
server.go
package auth
import ssov1 "github/ilKhr/protos" // <- could not import github/ilKhr/protos (no required module provides package "github/ilKhr/protos")
Share
Improve this question
asked Nov 18, 2024 at 14:12
Илья ХоришкоИлья Хоришко
1,2251 gold badge11 silver badges22 bronze badges
1 Answer
Reset to default -1The thing is that when I imported ssov1
incorrectly.
The correct import, it should be done manually, VS Code didn't do it automatically for me
I.e. literally you need to write import to the directory where Go files are located (see project structure).
server.go
package auth
import ssov1 "github/ilKhr/protos/gen/go/sso"
版权声明:本文标题:VS Code get `BrokenImport` error when I use `replace` in `go.mod` with local require development - Stack Overflow 内容由热心网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://it.en369.cn/questions/1745611686a2159037.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论