github.com/blend/go-sdk@v1.20220411.3/diff/operation.go (about)

     1  /*
     2  
     3  Copyright (c) 2022 - Present. Blend Labs, Inc. All rights reserved
     4  Use of this source code is governed by a MIT license that can be found in the LICENSE file.
     5  
     6  */
     7  
     8  package diff
     9  
    10  import "strconv"
    11  
    12  // Operation defines the operation of a diff item.
    13  type Operation int8
    14  
    15  // Operation constants.
    16  const (
    17  	// DiffDelete item represents a delete diff.
    18  	DiffDelete Operation = -1
    19  	// DiffInsert item represents an insert diff.
    20  	DiffInsert Operation = 1
    21  	// DiffEqual item represents an equal diff.
    22  	DiffEqual Operation = 0
    23  	//IndexSeparator is used to separate the array indexes in an index string
    24  	IndexSeparator = ","
    25  )
    26  
    27  func _() {
    28  	// An "invalid array index" compiler error signifies that the constant values have changed.
    29  	// Re-run the stringer command to generate them again.
    30  	var x [1]struct{}
    31  	_ = x[DiffDelete - -1]
    32  	_ = x[DiffInsert-1]
    33  	_ = x[DiffEqual-0]
    34  }
    35  
    36  const operationName = "DeleteEqualInsert"
    37  
    38  var operationIndex = [...]uint8{0, 6, 11, 17}
    39  
    40  func (i Operation) String() string {
    41  	i -= -1
    42  	if i < 0 || i >= Operation(len(operationIndex)-1) {
    43  		return "Operation(" + strconv.FormatInt(int64(i+-1), 10) + ")"
    44  	}
    45  	return operationName[operationIndex[i]:operationIndex[i+1]]
    46  }