Cant import from other file

Ive got my .proto file with a message that can be exported -

syntax = "proto3";

package domain;

option go_package = "BITBUCKET-REPOSITORY-MANAGEMENT-SERVICE/internal/gRPC/domain";

message Repoistory{
    int64 id = 1;
    string name = 2;
    int64 userId = 3;
    bool isPrivate = 4;
}

And another .proto file that import the Repository from the other -

syntax = "proto3";

package service;

option go_package = "BITBUCKET-REPOSITORY-MANAGEMENT-SERVICE/internal/gRPC/service";

import "github.com/MyWorkSpace/lets_Go/BITBUCKET-REPOSITORY-MANAGEMENT-SERVICE/internal/proto-files/domain/repository.proto";

//RepositoryService Definition
service RepositoryService {
    rpc add (domain.Repository) returns (AddRepositoryResponse);
}

message AddRepositoryResponse {
    domain.Repository addedRepository = 1;
    Error error = 2;
}

message Error {
    string code = 1;
    string message = 2;
}

But unfortunatly, when i try to install it with -
protoc --go_out=. repository-service.proto
i get this error everytime -
github.com/MyWorkSpace/lets_Go/BITBUCKET-REPOSITORY-MANAGEMENT-SERVICE/internal/proto-files/domain/repository.proto: File not found.
repository-service.proto:7:1: Import “github.com/MyWorkSpace/lets_Go/BITBUCKET-REPOSITORY-MANAGEMENT-SERVICE/internal/proto-files/domain/repository.proto” was not found or had errors.
repository-service.proto:15:5: “domain.Repository” is not defined.
repository-service.proto:11:14: “domain.Repository” is not defined.

basically says that it cant find my file. Im really not sure whats wrong because ive checked the path so many times, and still cant see the issue

this is the path of the file im trying to import from
C:\Users\justi\src\github.com\MyWorkSpace\lets_Go\BITBUCKET-REPOSITORY-MANAGEMENT-SERVICE\internal\proto-files\domain

2 Likes

same error unfortunately

2 Likes

Hello Justin,

it would help readability by ensuring the code in your question is properly formatted.
To do so, add three back ticks immediately followed by “go” in front of the first code line and append three back ticks after the last line. The line must start with the back ticks.

This will yield a nice formatting of your code.

3 Likes

Are you sure the file name is repository.proto and there is no typo in it ?

It could be that the location where you execute the protoc command matters because the import path is relative.

2 Likes

the path to the file is -
C:\Users\justi\src\github.com\MyWorkSpace\lets_Go\BITBUCKET-REPOSITORY-MANAGEMENT-SERVICE\internal\proto-files\domain\repository.proto

and im executing the protoc command in the folder where the other file is

2 Likes

I’ve got so many files. i guess thats why im having such an issue

2 Likes

thanks. this path is better. mine was getting too complicated

2 Likes

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.