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
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 3 additions & 7 deletions batch/index.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,10 @@ func NewIndex(key int) Index {
return Index{key: key}
}

// Create another type for Index so that MarshalText and UnmarshalText
// don't run into recursion issues.
type index Index

func (i Index) MarshalText() (text []byte, err error) {
return json.Marshal(index(i))
return json.Marshal(i.key)
}

func (i *Index) UnmarshalText(text []byte) error {
return json.Unmarshal(text, (*index)(i))
}
return json.Unmarshal(text, &i.key)
}