github.com/ssgreg/logf@v1.4.1/field.go (about) 1 package logf 2 3 import ( 4 "fmt" 5 "math" 6 "reflect" 7 "time" 8 "unsafe" 9 ) 10 11 // Bool returns a new Field with the given key and bool. 12 func Bool(k string, v bool) Field { 13 var tmp int64 14 if v { 15 tmp = 1 16 } 17 18 return Field{Key: k, Type: FieldTypeBool, Int: tmp} 19 } 20 21 // Int returns a new Field with the given key and int. 22 func Int(k string, v int) Field { 23 return Field{Key: k, Type: FieldTypeInt64, Int: int64(v)} 24 } 25 26 // Int64 returns a new Field with the given key and int64. 27 func Int64(k string, v int64) Field { 28 return Field{Key: k, Type: FieldTypeInt64, Int: v} 29 } 30 31 // Int32 returns a new Field with the given key and int32. 32 func Int32(k string, v int32) Field { 33 return Field{Key: k, Type: FieldTypeInt32, Int: int64(v)} 34 } 35 36 // Int16 returns a new Field with the given key and int16. 37 func Int16(k string, v int16) Field { 38 return Field{Key: k, Type: FieldTypeInt16, Int: int64(v)} 39 } 40 41 // Int8 returns a new Field with the given key and int.8 42 func Int8(k string, v int8) Field { 43 return Field{Key: k, Type: FieldTypeInt8, Int: int64(v)} 44 } 45 46 // Uint returns a new Field with the given key and uint. 47 func Uint(k string, v uint) Field { 48 return Field{Key: k, Type: FieldTypeUint64, Int: int64(v)} 49 } 50 51 // Uint64 returns a new Field with the given key and uint64. 52 func Uint64(k string, v uint64) Field { 53 return Field{Key: k, Type: FieldTypeUint64, Int: int64(v)} 54 } 55 56 // Uint32 returns a new Field with the given key and uint32. 57 func Uint32(k string, v uint32) Field { 58 return Field{Key: k, Type: FieldTypeUint32, Int: int64(v)} 59 } 60 61 // Uint16 returns a new Field with the given key and uint16. 62 func Uint16(k string, v uint16) Field { 63 return Field{Key: k, Type: FieldTypeUint16, Int: int64(v)} 64 } 65 66 // Uint8 returns a new Field with the given key and uint8. 67 func Uint8(k string, v uint8) Field { 68 return Field{Key: k, Type: FieldTypeUint8, Int: int64(v)} 69 } 70 71 // Float64 returns a new Field with the given key and float64. 72 func Float64(k string, v float64) Field { 73 return Field{Key: k, Type: FieldTypeFloat64, Int: int64(math.Float64bits(v))} 74 } 75 76 // Float32 returns a new Field with the given key and float32. 77 func Float32(k string, v float32) Field { 78 return Field{Key: k, Type: FieldTypeFloat32, Int: int64(math.Float32bits(v))} 79 } 80 81 // Duration returns a new Field with the given key and time.Duration. 82 func Duration(k string, v time.Duration) Field { 83 return Field{Key: k, Type: FieldTypeDuration, Int: int64(v)} 84 } 85 86 // Bytes returns a new Field with the given key and slice of bytes. 87 func Bytes(k string, v []byte) Field { 88 return Field{Key: k, Type: FieldTypeRawBytes, Bytes: v} 89 } 90 91 // String returns a new Field with the given key and string. 92 func String(k string, v string) Field { 93 return Field{Key: k, Type: FieldTypeBytesToString, Bytes: *(*[]byte)(unsafe.Pointer(&v))} 94 } 95 96 // Strings returns a new Field with the given key and slice of strings. 97 func Strings(k string, v []string) Field { 98 return Field{Key: k, Type: FieldTypeArray, Any: stringArray(v)} 99 } 100 101 type stringArray []string 102 103 func (o stringArray) EncodeLogfArray(e TypeEncoder) error { 104 for i := range o { 105 e.EncodeTypeString(o[i]) 106 } 107 108 return nil 109 } 110 111 // Bools returns a new Field with the given key and slice of bools. 112 func Bools(k string, v []bool) Field { 113 return Field{Key: k, Type: FieldTypeRawBytesToBools, Bytes: *(*[]byte)(unsafe.Pointer(&v))} 114 } 115 116 // Ints returns a new Field with the given key and slice of ints. 117 func Ints(k string, v []int) Field { 118 return Field{Key: k, Type: FieldTypeRawBytesToInts64, Bytes: *(*[]byte)(unsafe.Pointer(&v))} 119 } 120 121 // Ints64 returns a new Field with the given key and slice of 64-bit ints. 122 func Ints64(k string, v []int64) Field { 123 return Field{Key: k, Type: FieldTypeRawBytesToInts64, Bytes: *(*[]byte)(unsafe.Pointer(&v))} 124 } 125 126 // Ints32 returns a new Field with the given key and slice of 32-bit ints. 127 func Ints32(k string, v []int32) Field { 128 return Field{Key: k, Type: FieldTypeRawBytesToInts32, Bytes: *(*[]byte)(unsafe.Pointer(&v))} 129 } 130 131 // Ints16 returns a new Field with the given key and slice of 16-bit ints. 132 func Ints16(k string, v []int16) Field { 133 return Field{Key: k, Type: FieldTypeRawBytesToInts16, Bytes: *(*[]byte)(unsafe.Pointer(&v))} 134 } 135 136 // Ints8 returns a new Field with the given key and slice of 8-bit ints. 137 func Ints8(k string, v []int8) Field { 138 return Field{Key: k, Type: FieldTypeRawBytesToInts8, Bytes: *(*[]byte)(unsafe.Pointer(&v))} 139 } 140 141 // Uints returns a new Field with the given key and slice of uints. 142 func Uints(k string, v []uint) Field { 143 return Field{Key: k, Type: FieldTypeRawBytesToUints64, Bytes: *(*[]byte)(unsafe.Pointer(&v))} 144 } 145 146 // Uints64 returns a new Field with the given key and slice of 64-bit uints. 147 func Uints64(k string, v []uint64) Field { 148 return Field{Key: k, Type: FieldTypeRawBytesToUints64, Bytes: *(*[]byte)(unsafe.Pointer(&v))} 149 } 150 151 // Uints32 returns a new Field with the given key and slice of 32-bit uints. 152 func Uints32(k string, v []uint32) Field { 153 return Field{Key: k, Type: FieldTypeRawBytesToUints32, Bytes: *(*[]byte)(unsafe.Pointer(&v))} 154 } 155 156 // Uints16 returns a new Field with the given key and slice of 16-bit uints. 157 func Uints16(k string, v []uint16) Field { 158 return Field{Key: k, Type: FieldTypeRawBytesToUints16, Bytes: *(*[]byte)(unsafe.Pointer(&v))} 159 } 160 161 // Uints8 returns a new Field with the given key and slice of 8-bit uints. 162 func Uints8(k string, v []uint8) Field { 163 return Field{Key: k, Type: FieldTypeRawBytesToUints8, Bytes: *(*[]byte)(unsafe.Pointer(&v))} 164 } 165 166 // Floats64 returns a new Field with the given key and slice of 64-biy floats. 167 func Floats64(k string, v []float64) Field { 168 return Field{Key: k, Type: FieldTypeRawBytesToFloats64, Bytes: *(*[]byte)(unsafe.Pointer(&v))} 169 } 170 171 // Floats32 returns a new Field with the given key and slice of 32-bit floats. 172 func Floats32(k string, v []float32) Field { 173 return Field{Key: k, Type: FieldTypeRawBytesToFloats32, Bytes: *(*[]byte)(unsafe.Pointer(&v))} 174 } 175 176 // Durations returns a new Field with the given key and slice of time.Duration. 177 func Durations(k string, v []time.Duration) Field { 178 return Field{Key: k, Type: FieldTypeRawBytesToDurations, Bytes: *(*[]byte)(unsafe.Pointer(&v))} 179 } 180 181 // ConstBytes returns a new Field with the given key and slice of bytes. 182 // 183 // Call ConstBytes if your array is const. It has significantly less impact 184 // on the calling goroutine. 185 // 186 func ConstBytes(k string, v []byte) Field { 187 return Field{Key: k, Type: FieldTypeBytes, Bytes: v} 188 } 189 190 // ConstBools returns a new Field with the given key and slice of bools. 191 // 192 // Call ConstBools if your array is const. It has significantly less impact 193 // on the calling goroutine. 194 // 195 func ConstBools(k string, v []bool) Field { 196 return Field{Key: k, Type: FieldTypeBytesToBools, Bytes: *(*[]byte)(unsafe.Pointer(&v))} 197 } 198 199 // ConstInts returns a new Field with the given key and slice of ints. 200 // 201 // Call ConstInts if your array is const. It has significantly less impact 202 // on the calling goroutine. 203 // 204 func ConstInts(k string, v []int) Field { 205 return Field{Key: k, Type: FieldTypeBytesToInts64, Bytes: *(*[]byte)(unsafe.Pointer(&v))} 206 } 207 208 // ConstInts64 returns a new Field with the given key and slice of 64-bit ints. 209 // 210 // Call ConstInts64 if your array is const. It has significantly less impact 211 // on the calling goroutine. 212 // 213 func ConstInts64(k string, v []int64) Field { 214 return Field{Key: k, Type: FieldTypeBytesToInts64, Bytes: *(*[]byte)(unsafe.Pointer(&v))} 215 } 216 217 // ConstInts32 returns a new Field with the given key and slice of 32-bit ints. 218 // 219 // Call ConstInts32 if your array is const. It has significantly less impact 220 // on the calling goroutine. 221 // 222 func ConstInts32(k string, v []int32) Field { 223 return Field{Key: k, Type: FieldTypeBytesToInts32, Bytes: *(*[]byte)(unsafe.Pointer(&v))} 224 } 225 226 // ConstInts16 returns a new Field with the given key and slice of 16-bit ints. 227 // 228 // Call ConstInts16 if your array is const. It has significantly less impact 229 // on the calling goroutine. 230 // 231 func ConstInts16(k string, v []int16) Field { 232 return Field{Key: k, Type: FieldTypeBytesToInts16, Bytes: *(*[]byte)(unsafe.Pointer(&v))} 233 } 234 235 // ConstInts8 returns a new Field with the given key and slice of 8-bit ints. 236 // 237 // Call ConstInts8 if your array is const. It has significantly less impact 238 // on the calling goroutine. 239 // 240 func ConstInts8(k string, v []int8) Field { 241 return Field{Key: k, Type: FieldTypeBytesToInts8, Bytes: *(*[]byte)(unsafe.Pointer(&v))} 242 } 243 244 // ConstUints returns a new Field with the given key and slice of uints. 245 // 246 // Call ConstUints if your array is const. It has significantly less impact 247 // on the calling goroutine. 248 // 249 func ConstUints(k string, v []uint) Field { 250 return Field{Key: k, Type: FieldTypeBytesToUints64, Bytes: *(*[]byte)(unsafe.Pointer(&v))} 251 } 252 253 // ConstUints64 returns a new Field with the given key and slice of 64-bit uints. 254 // 255 // Call ConstUints64 if your array is const. It has significantly less impact 256 // on the calling goroutine. 257 // 258 func ConstUints64(k string, v []uint64) Field { 259 return Field{Key: k, Type: FieldTypeBytesToUints64, Bytes: *(*[]byte)(unsafe.Pointer(&v))} 260 } 261 262 // ConstUints32 returns a new Field with the given key and slice of 32-bit uints. 263 // 264 // Call ConstUints32 if your array is const. It has significantly less impact 265 // on the calling goroutine. 266 // 267 func ConstUints32(k string, v []uint32) Field { 268 return Field{Key: k, Type: FieldTypeBytesToUints32, Bytes: *(*[]byte)(unsafe.Pointer(&v))} 269 } 270 271 // ConstUints16 returns a new Field with the given key and slice of 16-bit uints. 272 // 273 // Call ConstUints16 if your array is const. It has significantly less impact 274 // on the calling goroutine. 275 // 276 func ConstUints16(k string, v []uint16) Field { 277 return Field{Key: k, Type: FieldTypeBytesToUints16, Bytes: *(*[]byte)(unsafe.Pointer(&v))} 278 } 279 280 // ConstUints8 returns a new Field with the given key and slice of 8-bit uints. 281 // 282 // Call ConstUints8 if your array is const. It has significantly less impact 283 // on the calling goroutine. 284 // 285 func ConstUints8(k string, v []uint8) Field { 286 return Field{Key: k, Type: FieldTypeBytesToUints8, Bytes: *(*[]byte)(unsafe.Pointer(&v))} 287 } 288 289 // ConstFloats64 returns a new Field with the given key and slice of 64-bit floats. 290 // 291 // Call ConstFloats64 if your array is const. It has significantly less impact 292 // on the calling goroutine. 293 // 294 func ConstFloats64(k string, v []float64) Field { 295 return Field{Key: k, Type: FieldTypeBytesToFloats64, Bytes: *(*[]byte)(unsafe.Pointer(&v))} 296 } 297 298 // ConstFloats32 returns a new Field with the given key and slice of 32-bit floats. 299 // 300 // Call ConstFloats32 if your array is const. It has significantly less impact 301 // on the calling goroutine. 302 // 303 func ConstFloats32(k string, v []float32) Field { 304 return Field{Key: k, Type: FieldTypeBytesToFloats32, Bytes: *(*[]byte)(unsafe.Pointer(&v))} 305 } 306 307 // ConstDurations returns a new Field with the given key and slice of time.Duration. 308 // 309 // Call ConstDurations if your array is const. It has significantly less impact 310 // on the calling goroutine. 311 // 312 func ConstDurations(k string, v []time.Duration) Field { 313 return Field{Key: k, Type: FieldTypeBytesToDurations, Bytes: *(*[]byte)(unsafe.Pointer(&v))} 314 } 315 316 // NamedError returns a new Field with the given key and error. 317 func NamedError(k string, v error) Field { 318 return Field{Key: k, Type: FieldTypeError, Any: v} 319 } 320 321 // Error returns a new Field with the given error. Key is 'error'. 322 func Error(v error) Field { 323 return NamedError("error", v) 324 } 325 326 // Time returns a new Field with the given key and time.Time. 327 func Time(k string, v time.Time) Field { 328 return Field{Key: k, Type: FieldTypeTime, Int: v.UnixNano(), Any: v.Location()} 329 } 330 331 // Array returns a new Field with the given key and ArrayEncoder. 332 func Array(k string, v ArrayEncoder) Field { 333 return Field{Key: k, Type: FieldTypeArray, Any: v} 334 } 335 336 // Object returns a new Field with the given key and ObjectEncoder. 337 func Object(k string, v ObjectEncoder) Field { 338 return Field{Key: k, Type: FieldTypeObject, Any: v} 339 } 340 341 // ConstStringer returns a new Field with the given key and Stringer. 342 // Call ConstStringer if your object is const. It has significantly less 343 // impact on the calling goroutine. 344 func ConstStringer(k string, v fmt.Stringer) Field { 345 return Field{Key: k, Type: FieldTypeStringer, Any: v} 346 } 347 348 // Stringer returns a new Field with the given key and Stringer. 349 func Stringer(k string, v fmt.Stringer) Field { 350 if v == nil { 351 return String(k, "nil") 352 } 353 354 return String(k, v.String()) 355 } 356 357 // ConstFormatter returns a new Field with the given key, verb and interface 358 // to format. 359 // 360 // Call ConstFormatter if your object is const. It has significantly less 361 // impact on the calling goroutine. 362 // 363 func ConstFormatter(k string, verb string, v interface{}) Field { 364 return Field{Key: k, Type: FieldTypeFormatter, Bytes: *(*[]byte)(unsafe.Pointer(&verb)), Any: v} 365 } 366 367 // ConstFormatterV returns a new Field with the given key and interface to 368 // format. It uses the predefined verb "%#v" (a Go-syntax representation of 369 // the value). 370 // 371 // Call ConstFormatterV if your object is const. It has significantly less 372 // impact on the calling goroutine. 373 // 374 func ConstFormatterV(k string, v interface{}) Field { 375 return ConstFormatter(k, "%#v", v) 376 } 377 378 // Formatter returns a new Field with the given key, verb and interface to 379 // format. 380 func Formatter(k string, verb string, v interface{}) Field { 381 return String(k, fmt.Sprintf(verb, v)) 382 } 383 384 // FormatterV returns a new Field with the given key and interface to format. 385 // It uses the predefined verb "%#v" (a Go-syntax representation of the value). 386 func FormatterV(k string, v interface{}) Field { 387 return Formatter(k, "%#v", v) 388 } 389 390 // Any returns a new Filed with the given key and value of any type. Is tries 391 // to choose the best way to represent key-value pair as a Field. 392 // 393 // Note that Any is not possible to choose ConstX methods. Use specific Field 394 // methods for better performance. 395 func Any(k string, v interface{}) Field { 396 switch rv := v.(type) { 397 case bool: 398 return Bool(k, rv) 399 case int: 400 return Int(k, rv) 401 case int64: 402 return Int64(k, rv) 403 case int32: 404 return Int32(k, rv) 405 case int16: 406 return Int16(k, rv) 407 case int8: 408 return Int8(k, rv) 409 case uint: 410 return Uint(k, rv) 411 case uint64: 412 return Uint64(k, rv) 413 case uint32: 414 return Uint32(k, rv) 415 case uint16: 416 return Uint16(k, rv) 417 case uint8: 418 return Uint8(k, rv) 419 case float64: 420 return Float64(k, rv) 421 case float32: 422 return Float32(k, rv) 423 case time.Time: 424 return Time(k, rv) 425 case time.Duration: 426 return Duration(k, rv) 427 case error: 428 return NamedError(k, rv) 429 case ArrayEncoder: 430 return Array(k, rv) 431 case ObjectEncoder: 432 return Object(k, rv) 433 case []byte: 434 return Bytes(k, rv) 435 case []string: 436 return Strings(k, rv) 437 case []bool: 438 return Bools(k, rv) 439 case []int: 440 return Ints(k, rv) 441 case []int64: 442 return Ints64(k, rv) 443 case []int32: 444 return Ints32(k, rv) 445 case []int16: 446 return Ints16(k, rv) 447 case []int8: 448 return Ints8(k, rv) 449 case []uint: 450 return Uints(k, rv) 451 case []uint64: 452 return Uints64(k, rv) 453 case []uint32: 454 return Uints32(k, rv) 455 case []uint16: 456 return Uints16(k, rv) 457 case []float64: 458 return Floats64(k, rv) 459 case []float32: 460 return Floats32(k, rv) 461 case []time.Duration: 462 return Durations(k, rv) 463 case string: 464 return String(k, rv) 465 case nil: 466 break 467 468 default: 469 switch reflect.TypeOf(rv).Kind() { 470 case reflect.String: 471 return String(k, reflect.ValueOf(rv).String()) 472 case reflect.Bool: 473 return Bool(k, reflect.ValueOf(rv).Bool()) 474 case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64: 475 return Int64(k, reflect.ValueOf(rv).Int()) 476 case reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64: 477 return Uint64(k, reflect.ValueOf(rv).Uint()) 478 case reflect.Float32, reflect.Float64: 479 return Float64(k, reflect.ValueOf(rv).Float()) 480 } 481 } 482 483 return Field{Key: k, Type: FieldTypeAny, Any: v} 484 } 485 486 // FieldType specifies how to handle Field data. 487 type FieldType byte 488 489 // Set of FileType values. 490 const ( 491 FieldTypeUnknown FieldType = iota 492 FieldTypeAny 493 FieldTypeBool 494 FieldTypeInt64 495 FieldTypeInt32 496 FieldTypeInt16 497 FieldTypeInt8 498 FieldTypeUint64 499 FieldTypeUint32 500 FieldTypeUint16 501 FieldTypeUint8 502 FieldTypeFloat64 503 FieldTypeFloat32 504 FieldTypeDuration 505 FieldTypeError 506 FieldTypeTime 507 508 FieldTypeBytes 509 FieldTypeBytesToString 510 FieldTypeBytesToBools 511 FieldTypeBytesToInts64 512 FieldTypeBytesToInts32 513 FieldTypeBytesToInts16 514 FieldTypeBytesToInts8 515 FieldTypeBytesToUints64 516 FieldTypeBytesToUints32 517 FieldTypeBytesToUints16 518 FieldTypeBytesToUints8 519 FieldTypeBytesToFloats64 520 FieldTypeBytesToFloats32 521 FieldTypeBytesToDurations 522 523 FieldTypeArray 524 FieldTypeObject 525 FieldTypeStringer 526 FieldTypeFormatter 527 ) 528 529 // Special cases that are processed during snapshoting phase. 530 const ( 531 FieldTypeRawMask FieldType = 1<<7 + iota 532 FieldTypeRawBytes 533 FieldTypeRawBytesToBools 534 FieldTypeRawBytesToInts64 535 FieldTypeRawBytesToInts32 536 FieldTypeRawBytesToInts16 537 FieldTypeRawBytesToInts8 538 FieldTypeRawBytesToUints64 539 FieldTypeRawBytesToUints32 540 FieldTypeRawBytesToUints16 541 FieldTypeRawBytesToUints8 542 FieldTypeRawBytesToFloats64 543 FieldTypeRawBytesToFloats32 544 FieldTypeRawBytesToDurations 545 ) 546 547 // Field hold data of a specific field. 548 type Field struct { 549 Key string 550 Type FieldType 551 Any interface{} 552 Int int64 553 Bytes []byte 554 } 555 556 // Accept interprets Field data according to FieldType and calls appropriate 557 // FieldEncoder function. 558 func (fd Field) Accept(v FieldEncoder) { 559 switch fd.Type { 560 case FieldTypeAny: 561 v.EncodeFieldAny(fd.Key, fd.Any) 562 case FieldTypeBool: 563 v.EncodeFieldBool(fd.Key, fd.Int != 0) 564 case FieldTypeInt64: 565 v.EncodeFieldInt64(fd.Key, fd.Int) 566 case FieldTypeInt32: 567 v.EncodeFieldInt32(fd.Key, int32(fd.Int)) 568 case FieldTypeInt16: 569 v.EncodeFieldInt16(fd.Key, int16(fd.Int)) 570 case FieldTypeInt8: 571 v.EncodeFieldInt8(fd.Key, int8(fd.Int)) 572 case FieldTypeUint64: 573 v.EncodeFieldUint64(fd.Key, uint64(fd.Int)) 574 case FieldTypeUint32: 575 v.EncodeFieldUint32(fd.Key, uint32(fd.Int)) 576 case FieldTypeUint16: 577 v.EncodeFieldUint16(fd.Key, uint16(fd.Int)) 578 case FieldTypeUint8: 579 v.EncodeFieldUint8(fd.Key, uint8(fd.Int)) 580 case FieldTypeFloat32: 581 v.EncodeFieldFloat32(fd.Key, math.Float32frombits(uint32(fd.Int))) 582 case FieldTypeFloat64: 583 v.EncodeFieldFloat64(fd.Key, math.Float64frombits(uint64(fd.Int))) 584 case FieldTypeDuration: 585 v.EncodeFieldDuration(fd.Key, time.Duration(fd.Int)) 586 case FieldTypeError: 587 if fd.Any != nil { 588 v.EncodeFieldError(fd.Key, fd.Any.(error)) 589 } else { 590 v.EncodeFieldError(fd.Key, nil) 591 } 592 case FieldTypeTime: 593 if fd.Any != nil { 594 v.EncodeFieldTime(fd.Key, time.Unix(0, fd.Int).In(fd.Any.(*time.Location))) 595 } else { 596 v.EncodeFieldTime(fd.Key, time.Unix(0, fd.Int)) 597 } 598 case FieldTypeArray: 599 if fd.Any != nil { 600 v.EncodeFieldArray(fd.Key, fd.Any.(ArrayEncoder)) 601 } else { 602 v.EncodeFieldString(fd.Key, "nil") 603 } 604 case FieldTypeObject: 605 if fd.Any != nil { 606 v.EncodeFieldObject(fd.Key, fd.Any.(ObjectEncoder)) 607 } else { 608 v.EncodeFieldString(fd.Key, "nil") 609 } 610 case FieldTypeStringer: 611 if fd.Any != nil { 612 v.EncodeFieldString(fd.Key, (fd.Any.(fmt.Stringer)).String()) 613 } else { 614 v.EncodeFieldString(fd.Key, "nil") 615 } 616 case FieldTypeFormatter: 617 v.EncodeFieldString(fd.Key, fmt.Sprintf(*(*string)(unsafe.Pointer(&fd.Bytes)), fd.Any)) 618 case FieldTypeBytes: 619 v.EncodeFieldBytes(fd.Key, fd.Bytes) 620 case FieldTypeBytesToString: 621 v.EncodeFieldString(fd.Key, *(*string)(unsafe.Pointer(&fd.Bytes))) 622 case FieldTypeBytesToBools: 623 v.EncodeFieldBools(fd.Key, *(*[]bool)(unsafe.Pointer(&fd.Bytes))) 624 case FieldTypeBytesToInts64: 625 v.EncodeFieldInts64(fd.Key, *(*[]int64)(unsafe.Pointer(&fd.Bytes))) 626 case FieldTypeBytesToInts32: 627 v.EncodeFieldInts32(fd.Key, *(*[]int32)(unsafe.Pointer(&fd.Bytes))) 628 case FieldTypeBytesToInts16: 629 v.EncodeFieldInts16(fd.Key, *(*[]int16)(unsafe.Pointer(&fd.Bytes))) 630 case FieldTypeBytesToInts8: 631 v.EncodeFieldInts8(fd.Key, *(*[]int8)(unsafe.Pointer(&fd.Bytes))) 632 case FieldTypeBytesToUints64: 633 v.EncodeFieldUints64(fd.Key, *(*[]uint64)(unsafe.Pointer(&fd.Bytes))) 634 case FieldTypeBytesToUints32: 635 v.EncodeFieldUints32(fd.Key, *(*[]uint32)(unsafe.Pointer(&fd.Bytes))) 636 case FieldTypeBytesToUints16: 637 v.EncodeFieldUints16(fd.Key, *(*[]uint16)(unsafe.Pointer(&fd.Bytes))) 638 case FieldTypeBytesToUints8: 639 v.EncodeFieldUints8(fd.Key, *(*[]uint8)(unsafe.Pointer(&fd.Bytes))) 640 case FieldTypeBytesToFloats64: 641 v.EncodeFieldFloats64(fd.Key, *(*[]float64)(unsafe.Pointer(&fd.Bytes))) 642 case FieldTypeBytesToFloats32: 643 v.EncodeFieldFloats32(fd.Key, *(*[]float32)(unsafe.Pointer(&fd.Bytes))) 644 case FieldTypeBytesToDurations: 645 v.EncodeFieldDurations(fd.Key, *(*[]time.Duration)(unsafe.Pointer(&fd.Bytes))) 646 } 647 }