@@ -163,11 +163,6 @@ func (e *Erf) Fmt() string {
163
163
return e .format
164
164
}
165
165
166
- // Len returns the length of arguments.
167
- func (e * Erf ) Len () int {
168
- return len (e .args )
169
- }
170
-
171
166
// Arg returns an argument value on the given index. It panics if index is out of range.
172
167
func (e * Erf ) Arg (index int ) interface {} {
173
168
if index < 0 || index >= len (e .args ) {
@@ -186,6 +181,11 @@ func (e *Erf) Args() []interface{} {
186
181
return result
187
182
}
188
183
184
+ // Len returns the length of all arguments.
185
+ func (e * Erf ) Len () int {
186
+ return len (e .args )
187
+ }
188
+
189
189
// Attach attaches tags to arguments, if arguments are given.
190
190
// If tag is "", it passes attaching tag to corresponding argument.
191
191
// It panics for given errors:
@@ -225,21 +225,25 @@ func (e *Erf) Attach2(tags ...string) error {
225
225
return e .Attach (tags ... )
226
226
}
227
227
228
- // TagsLen returns the length of tags.
229
- func (e * Erf ) TagsLen () int {
230
- return len (e .tags )
231
- }
232
-
233
228
// Tag returns an argument value on the given tag. It returns nil if tag is not found.
234
229
func (e * Erf ) Tag (tag string ) interface {} {
230
+ index := e .TagIndex (tag )
231
+ if index < 0 {
232
+ return nil
233
+ }
234
+ return e .args [index ]
235
+ }
236
+
237
+ // TagIndex returns index of an argument on the given tag. It returns -1 if tag is not found.
238
+ func (e * Erf ) TagIndex (tag string ) int {
235
239
index := - 1
236
240
if idx , ok := e .tagIndexes [tag ]; ok {
237
241
index = idx
238
242
}
239
243
if index < 0 || index >= len (e .args ) {
240
- return nil
244
+ return - 1
241
245
}
242
- return e . args [ index ]
246
+ return index
243
247
}
244
248
245
249
// Tags returns all tags sequentially. It returns nil if tags are not attached.
@@ -252,6 +256,11 @@ func (e *Erf) Tags() []string {
252
256
return result
253
257
}
254
258
259
+ // TagsLen returns the length of all tags.
260
+ func (e * Erf ) TagsLen () int {
261
+ return len (e .tags )
262
+ }
263
+
255
264
// PC returns all program counters.
256
265
func (e * Erf ) PC () []uintptr {
257
266
result := make ([]uintptr , len (e .pc ))
0 commit comments