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 ?
If you'd like
buf lint
(andgenerate
,breaking
, and other subcommands) to work from the root of your project, you may need abuf.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.