Skip to content
This repository has been archived by the owner on Feb 1, 2024. It is now read-only.

Commit

Permalink
Fix unkeyed literals in protobuf initialization
Browse files Browse the repository at this point in the history
The golang/protobuf dependency update on 4/30 forces users to use keyed
literals (e.g., foopb.Message{Name: "Golang", Age: 8} as opposed to
foopb.Message{"Golang", 8}). There were a few examples of the latter
that had to be updated.

Signed-off-by: Darian Plumb <[email protected]>
  • Loading branch information
dplumb94 committed May 1, 2018
1 parent 289dce3 commit 69c8acc
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
8 changes: 7 additions & 1 deletion sdk/go/src/sawtooth_sdk/processor/context.go
Original file line number Diff line number Diff line change
Expand Up @@ -309,7 +309,13 @@ func (self *Context) AddReceiptData(data []byte) error {
func (self *Context) AddEvent(event_type string, attributes []Attribute, event_data []byte) error {
event_attributes := make([]*events_pb2.Event_Attribute, 0, len(attributes))
for _, attribute := range attributes {
event_attributes = append(event_attributes, &events_pb2.Event_Attribute{attribute.Key, attribute.Value})
event_attributes = append(
event_attributes,
&events_pb2.Event_Attribute{
Key: attribute.Key,
Value: attribute.Value,
},
)
}

event := &events_pb2.Event{
Expand Down
8 changes: 7 additions & 1 deletion sdk/go/tests/state_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,13 @@ func TestAddEvent(t *testing.T) {
context := processor.NewContext(connection, "asdf")

event_attributes := make([]*events_pb2.Event_Attribute, 0)
event_attributes = append(event_attributes, &events_pb2.Event_Attribute{"key", "value"})
event_attributes = append(
event_attributes,
&events_pb2.Event_Attribute{
Key: "key",
Value: "value",
},
)

event := &events_pb2.Event{
EventType: "test",
Expand Down

0 comments on commit 69c8acc

Please sign in to comment.