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

go batch: marshaling index as a number #523

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

cdauphinee
Copy link

The index struct is currently marshaling to/from "{}", which makes it hard to add diagnostic logging to code that uses it.

This change marshals the index using its internal key; for example:

index1 := batch.NewIndex(1)
index2 := batch.NewIndex(2)
data := map[batch.Index]string {
  index1: "foo",
  index2: "bar",
}

json, _ := json.Marshal(data)

// json before change
{
  "{}": "foo",
  "{}": "bar"
}

// json after change
{
  1: "foo",
  2: "bar"
}

This is currently marshaling to/from "{}", which makes it hard to add
diagnostic logging to code that uses parallel maps with index keys.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants