Comments (4)
You'd also want to rename the types in the proto
, encoding/prototext
, and encoding/protojson
packages.
It's been a while, but I think we went with MarshalOptions
/UnmarshalOptions
, because the older proto package has proto.Unmarshaler
and proto.Marshaler
types that are interfaces describing a type which can marshal/unmarshal itself. Using a different name for the options type had less potential for confusion.
Renaming UnmarshalOptions
and adding type UnmarshalOptions = Unmarshaler
might not be a backwards-compatible change; I don't know how likely it is to cause breakage, but it will be user-visible to code using reflection to inspect types. If TGP and the ecosystem metrics pipeline report no problems, it's probably fine, though.
Personally, I'm dubious that the improvement is worth the churn. protodelim.UnmarshalOptions
is probably not used much, but proto.UnmarshalOptions
is.
from protobuf.
Renaming MarshalOptions
as Marshaler
sounds fine to me as long as the naming convention is consistently applied.
I can't quite remember, but I believe @neild is correct that the pre-existing Marshaler
and Unmarshaler
types were why the name wasn't chosen. IIRC, we developed the v2 API within the v1 API, so name conflicts were possible during the transition. For prior precedence, the v1 "jsonpb" package has a Marshaler
type that is effectively an options struct with actor methods hung off of it.
from protobuf.
As far as I understand, yeah, the type-alias wouldn’t introduce any overhead to performance or inlining. There’s already so much type aliasing in the standard library, that if it were a performance impact, then it should have been handled already.
from protobuf.
FWIW: I found the "options"-laden names confusing when studying the new API. I literally asked myself as I was reading the APIs: "Options, but for what? What's taking them?"
from protobuf.
Related Issues (20)
- Latest version of google.golang.org/protobuf (v1.33.0) is no longer compatible with the latest version of github.com/golang/protobuf (v1.5.3) HOT 7
- Add option to JSON marshal / unmarshal: StripEnumPrefix / AddEnumPrefix HOT 10
- How to properly define protobuf `oneof` fields? HOT 2
- How can I import a pre-compiled proto from another package? HOT 4
- protodesc: feature "message_encoding" (in Protobuf editions) triggers proto2 group validation checks HOT 11
- timestamppb.AsTime is incorrectly implemented for nil/zero values HOT 2
- missing replace in go.mod HOT 1
- protojson: fail to unmarshal JSON with reserved fields HOT 19
- Parsing protoc plugin option containing ',' HOT 5
- go_features.proto has incorrect package and error-prone file path HOT 5
- Tracking issue: Fully Lazy Extension decoding HOT 4
- feature: Generate test client / `bufconn` constructors HOT 4
- v1.33.0 breaks bazel build HOT 14
- Reflection: protopath parsing and path+message access HOT 7
- Proposal: Set go.mod Go language version to oldest supported Go version (1.21 currently) HOT 8
- Proposal: Add `Override` mode to `proto.Merge` HOT 2
- editions: maps are incorrectly serialized if file has default message encoding of DELIMITED HOT 5
- protodesc: too strict about proto3 field names when creating descriptors from FileDescriptorProto
- undefined: descriptorpb.Default_FileOptions_PhpGenericServices HOT 2
- `ProtoReflect().GetUnknown()` Not Working HOT 4
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from protobuf.