Hi there. First of all, I have to say that I am using the word “intellisence” to refer to code-completion, linting, code formatting, and stuff like that. I am using the setup env provided by @novabyte in this gist, with a small difference that I am using version 2.14.1 of Nakama and Nakama-pluginbuilder, and Nakama-common v1.9.0 due to a bug in matchmaking I encountered during upgrade from Nakama-common 1.4.0 to 1.8.0.
I am using vscode-insiders 1.51.0 and the official Go plugin v0.18.1.
we have a monolithic repository consisting of seperate directories for our unity client, backend, and protobuffers which are shared between the other two.
davaa/
├── Backend
├── Client
└── ProtoBuffers
// ./Backend/go.mod
module gitlab.com/mahdad-baghani/davaa
go 1.14
require (
github.com/golang/protobuf v1.4.3
github.com/heroiclabs/nakama-common v1.9.0
google.golang.org/protobuf v1.25.0
)
here is one simple protobuf I defined:
// ./ProtoBuffers/netcode_message_buffers.proto
syntax = "proto3";
package netcode;
option go_package = "gitlab.com/mahdad-baghani/davaa/protobuffers;netcode_buffers";
option csharp_namespace="Davaa.ProtocolBuffers";
message MatchResultBuf {
string winner = 1;
string loser = 2;
string sender = 3;
}
I compile protobufs to specific folders. In the case of my backend, its ./Backend/protobuffers/
. Up to now, everything is fine when it comes to “intellisence”. I have code completion, function signature tooltips, linter suggestions, error squigglies, etc. When I try to start my backend using docker-compose -f my_yml.yml up --build nakama
, I get the following error:
match/match.go:10:2: cannot find package "." in: /backend/protobuffers
In line 10, I am importing my compiled protobuf package as following :
netcode_buffers "gitlab.com/mahdad-baghani/davaa/protobuffers"
I suspect that it has to do with my this specific line in my Dockerfile:
WORKDIR /backend
and
COPY --from=builder /backend/backend.so /nakama/data/modules
as the error indicates that the package was not found in /backend/protobuffers
.
I can compile by changing the go_package
option in my protobuf definition by adding the /Bakcend/
so it actually points to the physical file that exists on disk
option go_package = "gitlab.com/mahdad-baghani/davaa/Backend/protobuffers;netcode_buffers";
Now I can compile regardless of VS Code showing just one error: cannot find package "gitlab.com/mahdad-baghani/davaa/protobuffers" in any of ...
. But, now, I cannot have intellisence if I want to use my type MatchResultBuf, or any other auto-generated types from protobuffer definitions for that matter.
What am I doing wrong?