Comments (7)
From awalterschulze on March 28, 2014 03:26:17
Does adding
option (gogoproto.enum_stringer_all) = true;
fix your issue?
from protobuf.
From jtolds on March 28, 2014 08:59:47
Yeah, that fixes it, but it seemed like the default behavior is supposed to match goprotobuf. I didn't expect to have to change any settings if I wanted to match the goprotobuf behavior.
from protobuf.
From awalterschulze on March 29, 2014 00:58:14
Ok but the default setting is
option (gogoproto.goproto_enum_stringer_all) = true;
and that matches the behaviour of goprotobuf.
Status: Done
from protobuf.
From jtolds on March 29, 2014 02:50:31
Given the following protocol buffer definition without any extensions,
message MyMessage {
enum MyEnum {
VAL1 = 1;
VAL2 = 2;
}
optional MyEnum setting = 1;
}
the following tests pass with goprotobuf but do not pass with gogoprotobuf.
package test
import (
"encoding/json"
"testing"
)
func TestString(t *testing.T) {
msg := &MyMessage{Setting: MyMessage_VAL1.Enum()}
if msg.Setting.String() != "VAL1" {
t.Fatal("string value expected")
}
}
func TestMarshalJSON(t *testing.T) {
data, err := json.Marshal(&MyMessage{Setting: MyMessage_VAL1.Enum()})
if err != nil {
t.Fatal(err)
}
var val interface{}
err = json.Unmarshal(data, &val)
if err != nil {
t.Fatal(err)
}
if (val.(map[string]interface{}))["setting"].(string) != "VAL1" {
t.Fatal("string value expected")
}
}
shouldn't they pass?
from protobuf.
From jtolds on March 29, 2014 02:51:42
Hopefully the provided test case is concrete enough, but my original ticket is poorly trying to explain that gogoprotobuf for some reason disables MarshalJSON on enums by default, and the only way to enable MarshalJSON for enums is to disable the default Stringer.
from protobuf.
From awalterschulze on March 29, 2014 03:25:40
I suspect you have not updated your goprotobuf, since October 2013 https://code.google.com/p/goprotobuf/source/detail?r=61664b8425f3e0e4371d4b56016b224b9d69cbbb This test fails on my February 2014 goprotobuf
from protobuf.
From jtolds on March 29, 2014 11:58:05
oh my goodness i'm so sorry for wasting your time. that's totally what happened
from protobuf.
Related Issues (20)
- panic: protobuf tag not enough fields in Empty.state HOT 1
- Enum filling with negative numbers will report an error, is it the Enum that does not support negative numbers?
- License question
- protoreflect
- Vulnerability?
- Panic: invalid Go type HOT 3
- github.com/gogo/protobuf is not installed
- Improper Input Validation in GoGo Protobuf HOT 1
- string time and duration
- oom
- Panic: reflect: Elem of invalid type HOT 1
- How to customize the name of an enumeration value, using the extension `enumvalue_customname ` seems unable to complete.
- m argument not work
- Call command.Generate(req *plugin.CodeGeneratorRequest) twice could cause bug.
- BUG: protoc-gen-gogofast not generate trailing comments
- How to generate parameter "description" in message of proto3 HOT 1
- proto: protect field access with lock to avoid possible data race
- proto: protect field access with lock to avoid possible data race
- Release v1.3.3 - Please please please create it pointing to v1.3.2
- Unsafe type assertion
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.