AddAt is the same as Add but insert/move the fields at the specific position. If pos < 0, then this method acts the same as calling Add. If pos > FieldsList total items, then the specified fields are inserted/moved at the end of the list.
(pos int, fields ...Field)
| 127 | // |
| 128 | // If pos > FieldsList total items, then the specified fields are inserted/moved at the end of the list. |
| 129 | func (l *FieldsList) AddAt(pos int, fields ...Field) { |
| 130 | total := len(*l) |
| 131 | |
| 132 | for i, f := range fields { |
| 133 | if pos < 0 { |
| 134 | l.add(-1, f) |
| 135 | } else if pos > total { |
| 136 | l.add(total+i, f) |
| 137 | } else { |
| 138 | l.add(pos+i, f) |
| 139 | } |
| 140 | } |
| 141 | } |
| 142 | |
| 143 | // AddMarshaledJSON parses the provided raw json data and adds the |
| 144 | // found fields into the current list (following the same rule as the Add method). |