Tag Archives: protobuf

“‘protoc-gen-go’ is not recognized as an internal or external command” – Go

Hi everyone,

I’m currently looking into Go and have hit the following error while trying to run proto:

`protoc-gen-go` is not recognized as an internal or external command

I am using Windows and have installed the required libraries:

go get -u github.com/golang/protobuf/proto
go get -u github.com/golang/protobuf/protoc-gen-go

In my case the issue turned out to be that proto-gen hadn’t been added to my path: E:\repos\gocode\bin

Note that the new path won’t be available until you restart your terminal.

A subsequent error I encountered was the following:

'protoc-gen-go-grpc' is not recognized as an internal or external command,
operable program or batch file.

I just had to run the following to resolve it:

go install google.golang.org/grpc/cmd/protoc-gen-go-grpc@latest

“protobuf” visual studio a namespace cannot directly contain members such as fields or methods

Hi everyone,

I ran into the following intellisense error while adding a new proto file:

“protobuf” visual studio a namespace cannot directly contain members such as fields or methods

This was one of many errors that were shown and appeared to be an issue with Intellisense mistaking the file for a normal class definition. The following appears to have fixed it:

1) Right click on the file and select “exclude from project”
2) Clean the solution and rebuild
3) Re-include the file in the project (you may have to toggle ‘Show All Files’ at the top of solution explorer to see the excluded item).


Automapper protobuf datetime to timestamp c#

Hi everyone,

I ran into the following error tonight while attempting to use automapper to map a datetime field to a protobuf timestamp property:

automapper missing type map “DateTime -> Timestamp”

To fix it, add the following to your mapping profile:

CreateMap().ConvertUsing(x => x.ToTimestamp());

I later hit a similar error parsing a different entity:

Type Map configuration:
Entity-> EntityDto
EntityService.Models.Entity-> EntityService.EntityDto

Destination Member:

—> System.ArgumentException: Conversion from DateTime to Timestamp requires the DateTime kind to be Utc (Parameter ‘dateTime’)

Implementing the following map appears to have resolved it:

CreateMap().ConvertUsing(x => Timestamp.FromDateTime(DateTime.SpecifyKind(x, DateTimeKind.Utc)));

If you’re planning to go the other way (timestamp -> datetime) you may also need the following:

CreateMap().ConvertUsing(x => x.ToDateTime());

I’m currently using the following base class in my library:

public class BaseMappingProfile : Profile
public BaseMappingProfile()
CreateMap().ConvertUsing(x => Timestamp.FromDateTime(DateTime.SpecifyKind(x, DateTimeKind.Utc)));
CreateMap().ConvertUsing(x => x.ToDateTime());

Google didn’t seem to turn up a lot so I thought I’d post it here in case it helps someone out!