From 31050506cd4297dbc0973d0f6dacf142858f6302 Mon Sep 17 00:00:00 2001 From: Josh Bleecher Snyder Date: Mon, 7 Aug 2017 08:41:44 -0700 Subject: [PATCH] Make Operation a stringer This makes for more pleasant debugging. --- diffmatchpatch/diff.go | 2 ++ diffmatchpatch/operation_string.go | 17 +++++++++++++++++ 2 files changed, 19 insertions(+) create mode 100644 diffmatchpatch/operation_string.go diff --git a/diffmatchpatch/diff.go b/diffmatchpatch/diff.go index 82ad7bc..dedf4ca 100644 --- a/diffmatchpatch/diff.go +++ b/diffmatchpatch/diff.go @@ -25,6 +25,8 @@ import ( // Operation defines the operation of a diff item. type Operation int8 +//go:generate stringer -type=Operation -trimprefix=Diff + const ( // DiffDelete item represents a delete diff. DiffDelete Operation = -1 diff --git a/diffmatchpatch/operation_string.go b/diffmatchpatch/operation_string.go new file mode 100644 index 0000000..533ec0d --- /dev/null +++ b/diffmatchpatch/operation_string.go @@ -0,0 +1,17 @@ +// Code generated by "stringer -type=Operation -trimprefix=Diff"; DO NOT EDIT. + +package diffmatchpatch + +import "fmt" + +const _Operation_name = "DeleteEqualInsert" + +var _Operation_index = [...]uint8{0, 6, 11, 17} + +func (i Operation) String() string { + i -= -1 + if i < 0 || i >= Operation(len(_Operation_index)-1) { + return fmt.Sprintf("Operation(%d)", i+-1) + } + return _Operation_name[_Operation_index[i]:_Operation_index[i+1]] +}