-1

VS code gives the following error when I use replace in go.mod:

could not import github.com/ilKhr/protos (no required module provides package ‘github.com/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.com/ilKhr/protos 
go 1.23.0

/sso/go.mod

module github.com/ilkhr/sso
go 1.23.0
require github.com/ilKhr/protos v0.0.0-unpublished
replace github.com/ilKhr/protos v0.0.0-unpublished => ../protos

server.go

package auth
import ssov1 "github.com/ilKhr/protos" // <- could not import github.com/ilKhr/protos (no required module provides package "github.com/ilKhr/protos")
asked Nov 18, 2024 at 14:12

1 Answer 1

-1

The 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.com/ilKhr/protos/gen/go/sso"
answered Nov 18, 2024 at 14:12
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.