4 ms·
This makes sense, did you implement this alongside grpc / protobuf? I'm curios about the way you handled zero values, field masks could be a solution, but I th
by fpopa 6y ago
This makes sense, did you implement this alongside grpc / protobuf?
I'm curios about the way you handled zero values, field masks could be a solution, but I think it would get bloaty.
- zemo 6y agofunc (db *actualStoreImplementation) GetTask(t *Task) error { if (t.ID != 0) { // query by ID, mutate the parameter, return nil } if (t.Tag != "") { // query by tag, mutate the parameter, return nil } return ErrWhatever } usually I have some other package that defines all of the types that can appear on the wire (which I often call `wire` because `proto` is taken by protobuf), define some exported interface in that package with an unexported method so that no other packages can define new types for that interface, and then have a method on my db structs that returns the wire types, like this: func (t Task) Public() wire.Value { return wire.Task{ // explicitly generate what you want } }