1

I have such a project structure:

vgm:
 -music:
   -app:
      -cmd
      -go.mod
   -migrations
   -proto:
      -buf.yaml
      -music_service:
         -album:
            -v1:
               -album.proto
               -service.proto
.env

Here is the alum file :

syntax = "proto3";

package music_service.album.v1;

option go_package = "github.com/mygitname/vgm/music/app/gen/go/music/album/v1;pb_music_album";

message Album {
    string album_id = 1;
    string title = 2;
    uint32 create_at = 3;
}

Now I want to write a service for this file:

syntax = "proto3";

package music_service.album.v1;

option go_package = "github.com/mygitname/vgm/music/app/gen/go/music/album/v1;pb_music_album";

import "music_service/album/v1/album.proto";

service AlbumService {
    rpc CreateAlbum(CreateAlbumRequest) returns (CreateAlbumResponse) {}
}
  

message CreateAlbumRequest {
    string title = 1;
}

message CreateAlbumResponse{
    Album album = 1;
}

And the import in this file does not work. If you run the command buf lint , then writes the following error:

proto\music_service\album\v1\service.proto:7:8:music_service/album/v1/album.proto: does not ex exist

I am writing grpc for the second time . Everything was fine the previous time. I don't understand the reason for the error. Does it depend that there is no go.mod here? I looked at the examples and it seems that this is not necessarily in the proto file. What could be the mistake ?

Alpharius
  • 489
  • 5
  • 12
  • The fact that the error starts with `proto\musi...` is suspicious. Please confirm that `buf.yaml` is in the `proto` folder? (based on the error I'd guess its in the `music` folder). – Brits Jan 15 '23 at 21:45
  • @Brits yes, it is in the proto folder, but the launch is made from the music folder – Alpharius Jan 15 '23 at 23:00
  • OK; I have replicated your setup (as far as I can) and `buf lint` does not return any errors. So it looks like the issue is something not provided so far - please add the contents of your `buf.yaml` and confirm what version of `buf` you are using. – Brits Jan 16 '23 at 00:47
  • Upgraded to buf 1.12.0 (from 1.11.0) and can now duplicate (works fine if I run `buf lint` from the `proto` folder but not from the parent). I suspect this is a bug... – Brits Jan 16 '23 at 03:31

1 Answers1

0

If you'd like buf lint (and generate, breaking, and other subcommands) to work from the root of your project, you may need a buf.work.yaml in the root of your project: https://docs.buf.build/reference/workspaces.

If that doesn't help, we're always available to help in our Slack: https://buf.build/links/slack.

akshayshah
  • 158
  • 8