GetRange returns string from the absolute of start to the absolute of end
(start, end int)
| 116 | |
| 117 | // GetRange returns string from the absolute of start to the absolute of end |
| 118 | func (s *String) GetRange(start, end int) []byte { |
| 119 | vlen := len(s.Meta.Value) |
| 120 | if end < 0 { |
| 121 | end = vlen + end |
| 122 | } |
| 123 | if start < 0 { |
| 124 | start = vlen + start |
| 125 | } |
| 126 | if start > end || start > vlen || end < 0 { |
| 127 | return nil |
| 128 | } |
| 129 | if end > vlen { |
| 130 | end = vlen - 1 |
| 131 | } |
| 132 | if start < 0 { |
| 133 | start = 0 |
| 134 | } |
| 135 | return s.Meta.Value[start : end+1] |
| 136 | } |
| 137 | |
| 138 | // SetRange overwrites part of the string stored at key, starting at the specified offset, for the entire length of value. |
| 139 | func (s *String) SetRange(offset int64, value []byte) ([]byte, error) { |
no outgoing calls