protobuf-go

Go Protobuf declarations and optional Fields in Go Struct (string pointers)

不打扰是莪最后的温柔 提交于 2021-01-27 14:09:17
问题 I am running into a bit of a problem with Protoc and my existing struct that contains nullable string fields. The struct I am trying to serialize for transmission contains a bunch of fields that are nullable in json (so we can distinguish between null , "" and a set value). type Message struct { Path *string `json:"path"` } So if a user sends a empty json string {} the Path will be nil and not "" , whereas {"path":""} is also valid and a different case from {"path": null} . The proto3

Go converting ptypes/struct Value to BSON

跟風遠走 提交于 2020-03-23 09:50:08
问题 Requirements Two services: Server - for writing blog posts to MongoDB Client - sends request to the first service The blog post has title of type string , and content which is a dynamic type - can be any JSON value. Protobuf syntax = "proto3"; package blog; option go_package = "blogpb"; import "google/protobuf/struct.proto"; message Blog { string id = 1; string title = 2; google.protobuf.Value content = 3; } message CreateBlogRequest { Blog blog = 1; } message CreateBlogResponse { Blog blog =