code
stringlengths
12
335k
docstring
stringlengths
20
20.8k
func_name
stringlengths
1
105
language
stringclasses
1 value
repo
stringclasses
498 values
path
stringlengths
5
172
url
stringlengths
43
235
license
stringclasses
4 values
func (stream *Stream) WriteStringWithHTMLEscaped(s string) { valLen := len(s) stream.buf = append(stream.buf, '"') // write string, the fast path, without utf8 and escape support i := 0 for ; i < valLen; i++ { c := s[i] if c < utf8.RuneSelf && htmlSafeSet[c] { stream.buf = append(stream.buf, c) } else { break } } if i == valLen { stream.buf = append(stream.buf, '"') return } writeStringSlowPathWithHTMLEscaped(stream, i, s, valLen) }
WriteStringWithHTMLEscaped write string to stream with html special characters escaped
WriteStringWithHTMLEscaped
go
k8snetworkplumbingwg/multus-cni
vendor/github.com/json-iterator/go/stream_str.go
https://github.com/k8snetworkplumbingwg/multus-cni/blob/master/vendor/github.com/json-iterator/go/stream_str.go
Apache-2.0
func (stream *Stream) WriteString(s string) { valLen := len(s) stream.buf = append(stream.buf, '"') // write string, the fast path, without utf8 and escape support i := 0 for ; i < valLen; i++ { c := s[i] if c > 31 && c != '"' && c != '\\' { stream.buf = append(stream.buf, c) } else { break } } if i == valLen { stream.buf = append(stream.buf, '"') return } writeStringSlowPath(stream, i, s, valLen) }
WriteString write string to stream without html escape
WriteString
go
k8snetworkplumbingwg/multus-cni
vendor/github.com/json-iterator/go/stream_str.go
https://github.com/k8snetworkplumbingwg/multus-cni/blob/master/vendor/github.com/json-iterator/go/stream_str.go
Apache-2.0
func (iter *Iterator) ReadUint8() (ret uint8) { val := iter.readUint32(iter.nextToken()) if val > math.MaxUint8 { iter.ReportError("ReadUint8", "overflow: "+strconv.FormatInt(int64(val), 10)) return } return uint8(val) }
ReadUint8 read uint8
ReadUint8
go
k8snetworkplumbingwg/multus-cni
vendor/github.com/json-iterator/go/iter_int.go
https://github.com/k8snetworkplumbingwg/multus-cni/blob/master/vendor/github.com/json-iterator/go/iter_int.go
Apache-2.0
func (iter *Iterator) ReadInt16() (ret int16) { c := iter.nextToken() if c == '-' { val := iter.readUint32(iter.readByte()) if val > math.MaxInt16+1 { iter.ReportError("ReadInt16", "overflow: "+strconv.FormatInt(int64(val), 10)) return } return -int16(val) } val := iter.readUint32(c) if val > math.MaxInt16 { iter.ReportError("ReadInt16", "overflow: "+strconv.FormatInt(int64(val), 10)) return } return int16(val) }
ReadInt16 read int16
ReadInt16
go
k8snetworkplumbingwg/multus-cni
vendor/github.com/json-iterator/go/iter_int.go
https://github.com/k8snetworkplumbingwg/multus-cni/blob/master/vendor/github.com/json-iterator/go/iter_int.go
Apache-2.0
func (iter *Iterator) ReadUint16() (ret uint16) { val := iter.readUint32(iter.nextToken()) if val > math.MaxUint16 { iter.ReportError("ReadUint16", "overflow: "+strconv.FormatInt(int64(val), 10)) return } return uint16(val) }
ReadUint16 read uint16
ReadUint16
go
k8snetworkplumbingwg/multus-cni
vendor/github.com/json-iterator/go/iter_int.go
https://github.com/k8snetworkplumbingwg/multus-cni/blob/master/vendor/github.com/json-iterator/go/iter_int.go
Apache-2.0
func (iter *Iterator) ReadInt32() (ret int32) { c := iter.nextToken() if c == '-' { val := iter.readUint32(iter.readByte()) if val > math.MaxInt32+1 { iter.ReportError("ReadInt32", "overflow: "+strconv.FormatInt(int64(val), 10)) return } return -int32(val) } val := iter.readUint32(c) if val > math.MaxInt32 { iter.ReportError("ReadInt32", "overflow: "+strconv.FormatInt(int64(val), 10)) return } return int32(val) }
ReadInt32 read int32
ReadInt32
go
k8snetworkplumbingwg/multus-cni
vendor/github.com/json-iterator/go/iter_int.go
https://github.com/k8snetworkplumbingwg/multus-cni/blob/master/vendor/github.com/json-iterator/go/iter_int.go
Apache-2.0
func (iter *Iterator) ReadUint32() (ret uint32) { return iter.readUint32(iter.nextToken()) }
ReadUint32 read uint32
ReadUint32
go
k8snetworkplumbingwg/multus-cni
vendor/github.com/json-iterator/go/iter_int.go
https://github.com/k8snetworkplumbingwg/multus-cni/blob/master/vendor/github.com/json-iterator/go/iter_int.go
Apache-2.0
func (iter *Iterator) ReadInt64() (ret int64) { c := iter.nextToken() if c == '-' { val := iter.readUint64(iter.readByte()) if val > math.MaxInt64+1 { iter.ReportError("ReadInt64", "overflow: "+strconv.FormatUint(uint64(val), 10)) return } return -int64(val) } val := iter.readUint64(c) if val > math.MaxInt64 { iter.ReportError("ReadInt64", "overflow: "+strconv.FormatUint(uint64(val), 10)) return } return int64(val) }
ReadInt64 read int64
ReadInt64
go
k8snetworkplumbingwg/multus-cni
vendor/github.com/json-iterator/go/iter_int.go
https://github.com/k8snetworkplumbingwg/multus-cni/blob/master/vendor/github.com/json-iterator/go/iter_int.go
Apache-2.0
func (iter *Iterator) ReadUint64() uint64 { return iter.readUint64(iter.nextToken()) }
ReadUint64 read uint64
ReadUint64
go
k8snetworkplumbingwg/multus-cni
vendor/github.com/json-iterator/go/iter_int.go
https://github.com/k8snetworkplumbingwg/multus-cni/blob/master/vendor/github.com/json-iterator/go/iter_int.go
Apache-2.0
func (structDescriptor *StructDescriptor) GetField(fieldName string) *Binding { for _, binding := range structDescriptor.Fields { if binding.Field.Name() == fieldName { return binding } } return nil }
GetField get one field from the descriptor by its name. Can not use map here to keep field orders.
GetField
go
k8snetworkplumbingwg/multus-cni
vendor/github.com/json-iterator/go/reflect_extension.go
https://github.com/k8snetworkplumbingwg/multus-cni/blob/master/vendor/github.com/json-iterator/go/reflect_extension.go
Apache-2.0
func (extension *DummyExtension) UpdateStructDescriptor(structDescriptor *StructDescriptor) { }
UpdateStructDescriptor No-op
UpdateStructDescriptor
go
k8snetworkplumbingwg/multus-cni
vendor/github.com/json-iterator/go/reflect_extension.go
https://github.com/k8snetworkplumbingwg/multus-cni/blob/master/vendor/github.com/json-iterator/go/reflect_extension.go
Apache-2.0
func (extension *DummyExtension) CreateMapKeyDecoder(typ reflect2.Type) ValDecoder { return nil }
CreateMapKeyDecoder No-op
CreateMapKeyDecoder
go
k8snetworkplumbingwg/multus-cni
vendor/github.com/json-iterator/go/reflect_extension.go
https://github.com/k8snetworkplumbingwg/multus-cni/blob/master/vendor/github.com/json-iterator/go/reflect_extension.go
Apache-2.0
func (extension *DummyExtension) CreateMapKeyEncoder(typ reflect2.Type) ValEncoder { return nil }
CreateMapKeyEncoder No-op
CreateMapKeyEncoder
go
k8snetworkplumbingwg/multus-cni
vendor/github.com/json-iterator/go/reflect_extension.go
https://github.com/k8snetworkplumbingwg/multus-cni/blob/master/vendor/github.com/json-iterator/go/reflect_extension.go
Apache-2.0
func (extension *DummyExtension) DecorateDecoder(typ reflect2.Type, decoder ValDecoder) ValDecoder { return decoder }
DecorateDecoder No-op
DecorateDecoder
go
k8snetworkplumbingwg/multus-cni
vendor/github.com/json-iterator/go/reflect_extension.go
https://github.com/k8snetworkplumbingwg/multus-cni/blob/master/vendor/github.com/json-iterator/go/reflect_extension.go
Apache-2.0
func (extension *DummyExtension) DecorateEncoder(typ reflect2.Type, encoder ValEncoder) ValEncoder { return encoder }
DecorateEncoder No-op
DecorateEncoder
go
k8snetworkplumbingwg/multus-cni
vendor/github.com/json-iterator/go/reflect_extension.go
https://github.com/k8snetworkplumbingwg/multus-cni/blob/master/vendor/github.com/json-iterator/go/reflect_extension.go
Apache-2.0
func (extension EncoderExtension) UpdateStructDescriptor(structDescriptor *StructDescriptor) { }
UpdateStructDescriptor No-op
UpdateStructDescriptor
go
k8snetworkplumbingwg/multus-cni
vendor/github.com/json-iterator/go/reflect_extension.go
https://github.com/k8snetworkplumbingwg/multus-cni/blob/master/vendor/github.com/json-iterator/go/reflect_extension.go
Apache-2.0
func (extension EncoderExtension) CreateEncoder(typ reflect2.Type) ValEncoder { return extension[typ] }
CreateEncoder get encoder from map
CreateEncoder
go
k8snetworkplumbingwg/multus-cni
vendor/github.com/json-iterator/go/reflect_extension.go
https://github.com/k8snetworkplumbingwg/multus-cni/blob/master/vendor/github.com/json-iterator/go/reflect_extension.go
Apache-2.0
func (extension EncoderExtension) CreateMapKeyDecoder(typ reflect2.Type) ValDecoder { return nil }
CreateMapKeyDecoder No-op
CreateMapKeyDecoder
go
k8snetworkplumbingwg/multus-cni
vendor/github.com/json-iterator/go/reflect_extension.go
https://github.com/k8snetworkplumbingwg/multus-cni/blob/master/vendor/github.com/json-iterator/go/reflect_extension.go
Apache-2.0
func (extension EncoderExtension) CreateMapKeyEncoder(typ reflect2.Type) ValEncoder { return nil }
CreateMapKeyEncoder No-op
CreateMapKeyEncoder
go
k8snetworkplumbingwg/multus-cni
vendor/github.com/json-iterator/go/reflect_extension.go
https://github.com/k8snetworkplumbingwg/multus-cni/blob/master/vendor/github.com/json-iterator/go/reflect_extension.go
Apache-2.0
func (extension EncoderExtension) DecorateDecoder(typ reflect2.Type, decoder ValDecoder) ValDecoder { return decoder }
DecorateDecoder No-op
DecorateDecoder
go
k8snetworkplumbingwg/multus-cni
vendor/github.com/json-iterator/go/reflect_extension.go
https://github.com/k8snetworkplumbingwg/multus-cni/blob/master/vendor/github.com/json-iterator/go/reflect_extension.go
Apache-2.0
func (extension EncoderExtension) DecorateEncoder(typ reflect2.Type, encoder ValEncoder) ValEncoder { return encoder }
DecorateEncoder No-op
DecorateEncoder
go
k8snetworkplumbingwg/multus-cni
vendor/github.com/json-iterator/go/reflect_extension.go
https://github.com/k8snetworkplumbingwg/multus-cni/blob/master/vendor/github.com/json-iterator/go/reflect_extension.go
Apache-2.0
func (extension DecoderExtension) UpdateStructDescriptor(structDescriptor *StructDescriptor) { }
UpdateStructDescriptor No-op
UpdateStructDescriptor
go
k8snetworkplumbingwg/multus-cni
vendor/github.com/json-iterator/go/reflect_extension.go
https://github.com/k8snetworkplumbingwg/multus-cni/blob/master/vendor/github.com/json-iterator/go/reflect_extension.go
Apache-2.0
func (extension DecoderExtension) CreateMapKeyDecoder(typ reflect2.Type) ValDecoder { return nil }
CreateMapKeyDecoder No-op
CreateMapKeyDecoder
go
k8snetworkplumbingwg/multus-cni
vendor/github.com/json-iterator/go/reflect_extension.go
https://github.com/k8snetworkplumbingwg/multus-cni/blob/master/vendor/github.com/json-iterator/go/reflect_extension.go
Apache-2.0
func (extension DecoderExtension) CreateMapKeyEncoder(typ reflect2.Type) ValEncoder { return nil }
CreateMapKeyEncoder No-op
CreateMapKeyEncoder
go
k8snetworkplumbingwg/multus-cni
vendor/github.com/json-iterator/go/reflect_extension.go
https://github.com/k8snetworkplumbingwg/multus-cni/blob/master/vendor/github.com/json-iterator/go/reflect_extension.go
Apache-2.0
func (extension DecoderExtension) CreateDecoder(typ reflect2.Type) ValDecoder { return extension[typ] }
CreateDecoder get decoder from map
CreateDecoder
go
k8snetworkplumbingwg/multus-cni
vendor/github.com/json-iterator/go/reflect_extension.go
https://github.com/k8snetworkplumbingwg/multus-cni/blob/master/vendor/github.com/json-iterator/go/reflect_extension.go
Apache-2.0
func (extension DecoderExtension) DecorateDecoder(typ reflect2.Type, decoder ValDecoder) ValDecoder { return decoder }
DecorateDecoder No-op
DecorateDecoder
go
k8snetworkplumbingwg/multus-cni
vendor/github.com/json-iterator/go/reflect_extension.go
https://github.com/k8snetworkplumbingwg/multus-cni/blob/master/vendor/github.com/json-iterator/go/reflect_extension.go
Apache-2.0
func (extension DecoderExtension) DecorateEncoder(typ reflect2.Type, encoder ValEncoder) ValEncoder { return encoder }
DecorateEncoder No-op
DecorateEncoder
go
k8snetworkplumbingwg/multus-cni
vendor/github.com/json-iterator/go/reflect_extension.go
https://github.com/k8snetworkplumbingwg/multus-cni/blob/master/vendor/github.com/json-iterator/go/reflect_extension.go
Apache-2.0
func RegisterTypeDecoderFunc(typ string, fun DecoderFunc) { typeDecoders[typ] = &funcDecoder{fun} }
RegisterTypeDecoderFunc register TypeDecoder for a type with function
RegisterTypeDecoderFunc
go
k8snetworkplumbingwg/multus-cni
vendor/github.com/json-iterator/go/reflect_extension.go
https://github.com/k8snetworkplumbingwg/multus-cni/blob/master/vendor/github.com/json-iterator/go/reflect_extension.go
Apache-2.0
func RegisterTypeDecoder(typ string, decoder ValDecoder) { typeDecoders[typ] = decoder }
RegisterTypeDecoder register TypeDecoder for a typ
RegisterTypeDecoder
go
k8snetworkplumbingwg/multus-cni
vendor/github.com/json-iterator/go/reflect_extension.go
https://github.com/k8snetworkplumbingwg/multus-cni/blob/master/vendor/github.com/json-iterator/go/reflect_extension.go
Apache-2.0
func RegisterFieldDecoderFunc(typ string, field string, fun DecoderFunc) { RegisterFieldDecoder(typ, field, &funcDecoder{fun}) }
RegisterFieldDecoderFunc register TypeDecoder for a struct field with function
RegisterFieldDecoderFunc
go
k8snetworkplumbingwg/multus-cni
vendor/github.com/json-iterator/go/reflect_extension.go
https://github.com/k8snetworkplumbingwg/multus-cni/blob/master/vendor/github.com/json-iterator/go/reflect_extension.go
Apache-2.0
func RegisterFieldDecoder(typ string, field string, decoder ValDecoder) { fieldDecoders[fmt.Sprintf("%s/%s", typ, field)] = decoder }
RegisterFieldDecoder register TypeDecoder for a struct field
RegisterFieldDecoder
go
k8snetworkplumbingwg/multus-cni
vendor/github.com/json-iterator/go/reflect_extension.go
https://github.com/k8snetworkplumbingwg/multus-cni/blob/master/vendor/github.com/json-iterator/go/reflect_extension.go
Apache-2.0
func RegisterTypeEncoderFunc(typ string, fun EncoderFunc, isEmptyFunc func(unsafe.Pointer) bool) { typeEncoders[typ] = &funcEncoder{fun, isEmptyFunc} }
RegisterTypeEncoderFunc register TypeEncoder for a type with encode/isEmpty function
RegisterTypeEncoderFunc
go
k8snetworkplumbingwg/multus-cni
vendor/github.com/json-iterator/go/reflect_extension.go
https://github.com/k8snetworkplumbingwg/multus-cni/blob/master/vendor/github.com/json-iterator/go/reflect_extension.go
Apache-2.0
func RegisterTypeEncoder(typ string, encoder ValEncoder) { typeEncoders[typ] = encoder }
RegisterTypeEncoder register TypeEncoder for a type
RegisterTypeEncoder
go
k8snetworkplumbingwg/multus-cni
vendor/github.com/json-iterator/go/reflect_extension.go
https://github.com/k8snetworkplumbingwg/multus-cni/blob/master/vendor/github.com/json-iterator/go/reflect_extension.go
Apache-2.0
func RegisterFieldEncoderFunc(typ string, field string, fun EncoderFunc, isEmptyFunc func(unsafe.Pointer) bool) { RegisterFieldEncoder(typ, field, &funcEncoder{fun, isEmptyFunc}) }
RegisterFieldEncoderFunc register TypeEncoder for a struct field with encode/isEmpty function
RegisterFieldEncoderFunc
go
k8snetworkplumbingwg/multus-cni
vendor/github.com/json-iterator/go/reflect_extension.go
https://github.com/k8snetworkplumbingwg/multus-cni/blob/master/vendor/github.com/json-iterator/go/reflect_extension.go
Apache-2.0
func RegisterFieldEncoder(typ string, field string, encoder ValEncoder) { fieldEncoders[fmt.Sprintf("%s/%s", typ, field)] = encoder }
RegisterFieldEncoder register TypeEncoder for a struct field
RegisterFieldEncoder
go
k8snetworkplumbingwg/multus-cni
vendor/github.com/json-iterator/go/reflect_extension.go
https://github.com/k8snetworkplumbingwg/multus-cni/blob/master/vendor/github.com/json-iterator/go/reflect_extension.go
Apache-2.0
func RegisterExtension(extension Extension) { extensions = append(extensions, extension) }
RegisterExtension register extension
RegisterExtension
go
k8snetworkplumbingwg/multus-cni
vendor/github.com/json-iterator/go/reflect_extension.go
https://github.com/k8snetworkplumbingwg/multus-cni/blob/master/vendor/github.com/json-iterator/go/reflect_extension.go
Apache-2.0
func WrapInt32(val int32) Any { return &int32Any{baseAny{}, val} }
WrapInt32 turn int32 into Any interface
WrapInt32
go
k8snetworkplumbingwg/multus-cni
vendor/github.com/json-iterator/go/any.go
https://github.com/k8snetworkplumbingwg/multus-cni/blob/master/vendor/github.com/json-iterator/go/any.go
Apache-2.0
func WrapInt64(val int64) Any { return &int64Any{baseAny{}, val} }
WrapInt64 turn int64 into Any interface
WrapInt64
go
k8snetworkplumbingwg/multus-cni
vendor/github.com/json-iterator/go/any.go
https://github.com/k8snetworkplumbingwg/multus-cni/blob/master/vendor/github.com/json-iterator/go/any.go
Apache-2.0
func WrapUint32(val uint32) Any { return &uint32Any{baseAny{}, val} }
WrapUint32 turn uint32 into Any interface
WrapUint32
go
k8snetworkplumbingwg/multus-cni
vendor/github.com/json-iterator/go/any.go
https://github.com/k8snetworkplumbingwg/multus-cni/blob/master/vendor/github.com/json-iterator/go/any.go
Apache-2.0
func WrapUint64(val uint64) Any { return &uint64Any{baseAny{}, val} }
WrapUint64 turn uint64 into Any interface
WrapUint64
go
k8snetworkplumbingwg/multus-cni
vendor/github.com/json-iterator/go/any.go
https://github.com/k8snetworkplumbingwg/multus-cni/blob/master/vendor/github.com/json-iterator/go/any.go
Apache-2.0
func WrapFloat64(val float64) Any { return &floatAny{baseAny{}, val} }
WrapFloat64 turn float64 into Any interface
WrapFloat64
go
k8snetworkplumbingwg/multus-cni
vendor/github.com/json-iterator/go/any.go
https://github.com/k8snetworkplumbingwg/multus-cni/blob/master/vendor/github.com/json-iterator/go/any.go
Apache-2.0
func WrapString(val string) Any { return &stringAny{baseAny{}, val} }
WrapString turn string into Any interface
WrapString
go
k8snetworkplumbingwg/multus-cni
vendor/github.com/json-iterator/go/any.go
https://github.com/k8snetworkplumbingwg/multus-cni/blob/master/vendor/github.com/json-iterator/go/any.go
Apache-2.0
func Wrap(val interface{}) Any { if val == nil { return &nilAny{} } asAny, isAny := val.(Any) if isAny { return asAny } typ := reflect2.TypeOf(val) switch typ.Kind() { case reflect.Slice: return wrapArray(val) case reflect.Struct: return wrapStruct(val) case reflect.Map: return wrapMap(val) case reflect.String: return WrapString(val.(string)) case reflect.Int: if strconv.IntSize == 32 { return WrapInt32(int32(val.(int))) } return WrapInt64(int64(val.(int))) case reflect.Int8: return WrapInt32(int32(val.(int8))) case reflect.Int16: return WrapInt32(int32(val.(int16))) case reflect.Int32: return WrapInt32(val.(int32)) case reflect.Int64: return WrapInt64(val.(int64)) case reflect.Uint: if strconv.IntSize == 32 { return WrapUint32(uint32(val.(uint))) } return WrapUint64(uint64(val.(uint))) case reflect.Uintptr: if ptrSize == 32 { return WrapUint32(uint32(val.(uintptr))) } return WrapUint64(uint64(val.(uintptr))) case reflect.Uint8: return WrapUint32(uint32(val.(uint8))) case reflect.Uint16: return WrapUint32(uint32(val.(uint16))) case reflect.Uint32: return WrapUint32(uint32(val.(uint32))) case reflect.Uint64: return WrapUint64(val.(uint64)) case reflect.Float32: return WrapFloat64(float64(val.(float32))) case reflect.Float64: return WrapFloat64(val.(float64)) case reflect.Bool: if val.(bool) == true { return &trueAny{} } return &falseAny{} } return &invalidAny{baseAny{}, fmt.Errorf("unsupported type: %v", typ)} }
Wrap turn a go object into Any interface
Wrap
go
k8snetworkplumbingwg/multus-cni
vendor/github.com/json-iterator/go/any.go
https://github.com/k8snetworkplumbingwg/multus-cni/blob/master/vendor/github.com/json-iterator/go/any.go
Apache-2.0
func (iter *Iterator) ReadAny() Any { return iter.readAny() }
ReadAny read next JSON element as an Any object. It is a better json.RawMessage.
ReadAny
go
k8snetworkplumbingwg/multus-cni
vendor/github.com/json-iterator/go/any.go
https://github.com/k8snetworkplumbingwg/multus-cni/blob/master/vendor/github.com/json-iterator/go/any.go
Apache-2.0
func NewStream(cfg API, out io.Writer, bufSize int) *Stream { return &Stream{ cfg: cfg.(*frozenConfig), out: out, buf: make([]byte, 0, bufSize), Error: nil, indention: 0, } }
NewStream create new stream instance. cfg can be jsoniter.ConfigDefault. out can be nil if write to internal buffer. bufSize is the initial size for the internal buffer in bytes.
NewStream
go
k8snetworkplumbingwg/multus-cni
vendor/github.com/json-iterator/go/stream.go
https://github.com/k8snetworkplumbingwg/multus-cni/blob/master/vendor/github.com/json-iterator/go/stream.go
Apache-2.0
func (stream *Stream) Pool() StreamPool { return stream.cfg }
Pool returns a pool can provide more stream with same configuration
Pool
go
k8snetworkplumbingwg/multus-cni
vendor/github.com/json-iterator/go/stream.go
https://github.com/k8snetworkplumbingwg/multus-cni/blob/master/vendor/github.com/json-iterator/go/stream.go
Apache-2.0
func (stream *Stream) Reset(out io.Writer) { stream.out = out stream.buf = stream.buf[:0] }
Reset reuse this stream instance by assign a new writer
Reset
go
k8snetworkplumbingwg/multus-cni
vendor/github.com/json-iterator/go/stream.go
https://github.com/k8snetworkplumbingwg/multus-cni/blob/master/vendor/github.com/json-iterator/go/stream.go
Apache-2.0
func (stream *Stream) Available() int { return cap(stream.buf) - len(stream.buf) }
Available returns how many bytes are unused in the buffer.
Available
go
k8snetworkplumbingwg/multus-cni
vendor/github.com/json-iterator/go/stream.go
https://github.com/k8snetworkplumbingwg/multus-cni/blob/master/vendor/github.com/json-iterator/go/stream.go
Apache-2.0
func (stream *Stream) Buffered() int { return len(stream.buf) }
Buffered returns the number of bytes that have been written into the current buffer.
Buffered
go
k8snetworkplumbingwg/multus-cni
vendor/github.com/json-iterator/go/stream.go
https://github.com/k8snetworkplumbingwg/multus-cni/blob/master/vendor/github.com/json-iterator/go/stream.go
Apache-2.0
func (stream *Stream) Buffer() []byte { return stream.buf }
Buffer if writer is nil, use this method to take the result
Buffer
go
k8snetworkplumbingwg/multus-cni
vendor/github.com/json-iterator/go/stream.go
https://github.com/k8snetworkplumbingwg/multus-cni/blob/master/vendor/github.com/json-iterator/go/stream.go
Apache-2.0
func (stream *Stream) SetBuffer(buf []byte) { stream.buf = buf }
SetBuffer allows to append to the internal buffer directly
SetBuffer
go
k8snetworkplumbingwg/multus-cni
vendor/github.com/json-iterator/go/stream.go
https://github.com/k8snetworkplumbingwg/multus-cni/blob/master/vendor/github.com/json-iterator/go/stream.go
Apache-2.0
func (stream *Stream) Write(p []byte) (nn int, err error) { stream.buf = append(stream.buf, p...) if stream.out != nil { nn, err = stream.out.Write(stream.buf) stream.buf = stream.buf[nn:] return } return len(p), nil }
Write writes the contents of p into the buffer. It returns the number of bytes written. If nn < len(p), it also returns an error explaining why the write is short.
Write
go
k8snetworkplumbingwg/multus-cni
vendor/github.com/json-iterator/go/stream.go
https://github.com/k8snetworkplumbingwg/multus-cni/blob/master/vendor/github.com/json-iterator/go/stream.go
Apache-2.0
func (stream *Stream) writeByte(c byte) { stream.buf = append(stream.buf, c) }
WriteByte writes a single byte.
writeByte
go
k8snetworkplumbingwg/multus-cni
vendor/github.com/json-iterator/go/stream.go
https://github.com/k8snetworkplumbingwg/multus-cni/blob/master/vendor/github.com/json-iterator/go/stream.go
Apache-2.0
func (stream *Stream) Flush() error { if stream.out == nil { return nil } if stream.Error != nil { return stream.Error } _, err := stream.out.Write(stream.buf) if err != nil { if stream.Error == nil { stream.Error = err } return err } stream.buf = stream.buf[:0] return nil }
Flush writes any buffered data to the underlying io.Writer.
Flush
go
k8snetworkplumbingwg/multus-cni
vendor/github.com/json-iterator/go/stream.go
https://github.com/k8snetworkplumbingwg/multus-cni/blob/master/vendor/github.com/json-iterator/go/stream.go
Apache-2.0
func (stream *Stream) WriteRaw(s string) { stream.buf = append(stream.buf, s...) }
WriteRaw write string out without quotes, just like []byte
WriteRaw
go
k8snetworkplumbingwg/multus-cni
vendor/github.com/json-iterator/go/stream.go
https://github.com/k8snetworkplumbingwg/multus-cni/blob/master/vendor/github.com/json-iterator/go/stream.go
Apache-2.0
func (stream *Stream) WriteNil() { stream.writeFourBytes('n', 'u', 'l', 'l') }
WriteNil write null to stream
WriteNil
go
k8snetworkplumbingwg/multus-cni
vendor/github.com/json-iterator/go/stream.go
https://github.com/k8snetworkplumbingwg/multus-cni/blob/master/vendor/github.com/json-iterator/go/stream.go
Apache-2.0
func (stream *Stream) WriteTrue() { stream.writeFourBytes('t', 'r', 'u', 'e') }
WriteTrue write true to stream
WriteTrue
go
k8snetworkplumbingwg/multus-cni
vendor/github.com/json-iterator/go/stream.go
https://github.com/k8snetworkplumbingwg/multus-cni/blob/master/vendor/github.com/json-iterator/go/stream.go
Apache-2.0
func (stream *Stream) WriteFalse() { stream.writeFiveBytes('f', 'a', 'l', 's', 'e') }
WriteFalse write false to stream
WriteFalse
go
k8snetworkplumbingwg/multus-cni
vendor/github.com/json-iterator/go/stream.go
https://github.com/k8snetworkplumbingwg/multus-cni/blob/master/vendor/github.com/json-iterator/go/stream.go
Apache-2.0
func (stream *Stream) WriteBool(val bool) { if val { stream.WriteTrue() } else { stream.WriteFalse() } }
WriteBool write true or false into stream
WriteBool
go
k8snetworkplumbingwg/multus-cni
vendor/github.com/json-iterator/go/stream.go
https://github.com/k8snetworkplumbingwg/multus-cni/blob/master/vendor/github.com/json-iterator/go/stream.go
Apache-2.0
func (stream *Stream) WriteObjectStart() { stream.indention += stream.cfg.indentionStep stream.writeByte('{') stream.writeIndention(0) }
WriteObjectStart write { with possible indention
WriteObjectStart
go
k8snetworkplumbingwg/multus-cni
vendor/github.com/json-iterator/go/stream.go
https://github.com/k8snetworkplumbingwg/multus-cni/blob/master/vendor/github.com/json-iterator/go/stream.go
Apache-2.0
func (stream *Stream) WriteObjectField(field string) { stream.WriteString(field) if stream.indention > 0 { stream.writeTwoBytes(':', ' ') } else { stream.writeByte(':') } }
WriteObjectField write "field": with possible indention
WriteObjectField
go
k8snetworkplumbingwg/multus-cni
vendor/github.com/json-iterator/go/stream.go
https://github.com/k8snetworkplumbingwg/multus-cni/blob/master/vendor/github.com/json-iterator/go/stream.go
Apache-2.0
func (stream *Stream) WriteObjectEnd() { stream.writeIndention(stream.cfg.indentionStep) stream.indention -= stream.cfg.indentionStep stream.writeByte('}') }
WriteObjectEnd write } with possible indention
WriteObjectEnd
go
k8snetworkplumbingwg/multus-cni
vendor/github.com/json-iterator/go/stream.go
https://github.com/k8snetworkplumbingwg/multus-cni/blob/master/vendor/github.com/json-iterator/go/stream.go
Apache-2.0
func (stream *Stream) WriteEmptyObject() { stream.writeByte('{') stream.writeByte('}') }
WriteEmptyObject write {}
WriteEmptyObject
go
k8snetworkplumbingwg/multus-cni
vendor/github.com/json-iterator/go/stream.go
https://github.com/k8snetworkplumbingwg/multus-cni/blob/master/vendor/github.com/json-iterator/go/stream.go
Apache-2.0
func (stream *Stream) WriteMore() { stream.writeByte(',') stream.writeIndention(0) }
WriteMore write , with possible indention
WriteMore
go
k8snetworkplumbingwg/multus-cni
vendor/github.com/json-iterator/go/stream.go
https://github.com/k8snetworkplumbingwg/multus-cni/blob/master/vendor/github.com/json-iterator/go/stream.go
Apache-2.0
func (stream *Stream) WriteArrayStart() { stream.indention += stream.cfg.indentionStep stream.writeByte('[') stream.writeIndention(0) }
WriteArrayStart write [ with possible indention
WriteArrayStart
go
k8snetworkplumbingwg/multus-cni
vendor/github.com/json-iterator/go/stream.go
https://github.com/k8snetworkplumbingwg/multus-cni/blob/master/vendor/github.com/json-iterator/go/stream.go
Apache-2.0
func (stream *Stream) WriteEmptyArray() { stream.writeTwoBytes('[', ']') }
WriteEmptyArray write []
WriteEmptyArray
go
k8snetworkplumbingwg/multus-cni
vendor/github.com/json-iterator/go/stream.go
https://github.com/k8snetworkplumbingwg/multus-cni/blob/master/vendor/github.com/json-iterator/go/stream.go
Apache-2.0
func (stream *Stream) WriteArrayEnd() { stream.writeIndention(stream.cfg.indentionStep) stream.indention -= stream.cfg.indentionStep stream.writeByte(']') }
WriteArrayEnd write ] with possible indention
WriteArrayEnd
go
k8snetworkplumbingwg/multus-cni
vendor/github.com/json-iterator/go/stream.go
https://github.com/k8snetworkplumbingwg/multus-cni/blob/master/vendor/github.com/json-iterator/go/stream.go
Apache-2.0
func (cfg Config) Froze() API { api := &frozenConfig{ sortMapKeys: cfg.SortMapKeys, indentionStep: cfg.IndentionStep, objectFieldMustBeSimpleString: cfg.ObjectFieldMustBeSimpleString, onlyTaggedField: cfg.OnlyTaggedField, disallowUnknownFields: cfg.DisallowUnknownFields, caseSensitive: cfg.CaseSensitive, } api.streamPool = &sync.Pool{ New: func() interface{} { return NewStream(api, nil, 512) }, } api.iteratorPool = &sync.Pool{ New: func() interface{} { return NewIterator(api) }, } api.initCache() encoderExtension := EncoderExtension{} decoderExtension := DecoderExtension{} if cfg.MarshalFloatWith6Digits { api.marshalFloatWith6Digits(encoderExtension) } if cfg.EscapeHTML { api.escapeHTML(encoderExtension) } if cfg.UseNumber { api.useNumber(decoderExtension) } if cfg.ValidateJsonRawMessage { api.validateJsonRawMessage(encoderExtension) } api.encoderExtension = encoderExtension api.decoderExtension = decoderExtension api.configBeforeFrozen = cfg return api }
Froze forge API from config
Froze
go
k8snetworkplumbingwg/multus-cni
vendor/github.com/json-iterator/go/config.go
https://github.com/k8snetworkplumbingwg/multus-cni/blob/master/vendor/github.com/json-iterator/go/config.go
Apache-2.0
func (cfg *frozenConfig) marshalFloatWith6Digits(extension EncoderExtension) { // for better performance extension[reflect2.TypeOfPtr((*float32)(nil)).Elem()] = &lossyFloat32Encoder{} extension[reflect2.TypeOfPtr((*float64)(nil)).Elem()] = &lossyFloat64Encoder{} }
EnableLossyFloatMarshalling keeps 10**(-6) precision for float variables for better performance.
marshalFloatWith6Digits
go
k8snetworkplumbingwg/multus-cni
vendor/github.com/json-iterator/go/config.go
https://github.com/k8snetworkplumbingwg/multus-cni/blob/master/vendor/github.com/json-iterator/go/config.go
Apache-2.0
func (iter *Iterator) ReadNil() (ret bool) { c := iter.nextToken() if c == 'n' { iter.skipThreeBytes('u', 'l', 'l') // null return true } iter.unreadByte() return false }
ReadNil reads a json object as nil and returns whether it's a nil or not
ReadNil
go
k8snetworkplumbingwg/multus-cni
vendor/github.com/json-iterator/go/iter_skip.go
https://github.com/k8snetworkplumbingwg/multus-cni/blob/master/vendor/github.com/json-iterator/go/iter_skip.go
Apache-2.0
func (iter *Iterator) ReadBool() (ret bool) { c := iter.nextToken() if c == 't' { iter.skipThreeBytes('r', 'u', 'e') return true } if c == 'f' { iter.skipFourBytes('a', 'l', 's', 'e') return false } iter.ReportError("ReadBool", "expect t or f, but found "+string([]byte{c})) return }
ReadBool reads a json object as BoolValue
ReadBool
go
k8snetworkplumbingwg/multus-cni
vendor/github.com/json-iterator/go/iter_skip.go
https://github.com/k8snetworkplumbingwg/multus-cni/blob/master/vendor/github.com/json-iterator/go/iter_skip.go
Apache-2.0
func (iter *Iterator) SkipAndReturnBytes() []byte { iter.startCapture(iter.head) iter.Skip() return iter.stopCapture() }
SkipAndReturnBytes skip next JSON element, and return its content as []byte. The []byte can be kept, it is a copy of data.
SkipAndReturnBytes
go
k8snetworkplumbingwg/multus-cni
vendor/github.com/json-iterator/go/iter_skip.go
https://github.com/k8snetworkplumbingwg/multus-cni/blob/master/vendor/github.com/json-iterator/go/iter_skip.go
Apache-2.0
func (iter *Iterator) SkipAndAppendBytes(buf []byte) []byte { iter.startCaptureTo(buf, iter.head) iter.Skip() return iter.stopCapture() }
SkipAndAppendBytes skips next JSON element and appends its content to buffer, returning the result.
SkipAndAppendBytes
go
k8snetworkplumbingwg/multus-cni
vendor/github.com/json-iterator/go/iter_skip.go
https://github.com/k8snetworkplumbingwg/multus-cni/blob/master/vendor/github.com/json-iterator/go/iter_skip.go
Apache-2.0
func (iter *Iterator) Skip() { c := iter.nextToken() switch c { case '"': iter.skipString() case 'n': iter.skipThreeBytes('u', 'l', 'l') // null case 't': iter.skipThreeBytes('r', 'u', 'e') // true case 'f': iter.skipFourBytes('a', 'l', 's', 'e') // false case '0': iter.unreadByte() iter.ReadFloat32() case '-', '1', '2', '3', '4', '5', '6', '7', '8', '9': iter.skipNumber() case '[': iter.skipArray() case '{': iter.skipObject() default: iter.ReportError("Skip", fmt.Sprintf("do not know how to skip: %v", c)) return } }
Skip skips a json object and positions to relatively the next json object
Skip
go
k8snetworkplumbingwg/multus-cni
vendor/github.com/json-iterator/go/iter_skip.go
https://github.com/k8snetworkplumbingwg/multus-cni/blob/master/vendor/github.com/json-iterator/go/iter_skip.go
Apache-2.0
func Unmarshal(data []byte, v interface{}) error { return ConfigDefault.Unmarshal(data, v) }
Unmarshal adapts to json/encoding Unmarshal API Unmarshal parses the JSON-encoded data and stores the result in the value pointed to by v. Refer to https://godoc.org/encoding/json#Unmarshal for more information
Unmarshal
go
k8snetworkplumbingwg/multus-cni
vendor/github.com/json-iterator/go/adapter.go
https://github.com/k8snetworkplumbingwg/multus-cni/blob/master/vendor/github.com/json-iterator/go/adapter.go
Apache-2.0
func UnmarshalFromString(str string, v interface{}) error { return ConfigDefault.UnmarshalFromString(str, v) }
UnmarshalFromString is a convenient method to read from string instead of []byte
UnmarshalFromString
go
k8snetworkplumbingwg/multus-cni
vendor/github.com/json-iterator/go/adapter.go
https://github.com/k8snetworkplumbingwg/multus-cni/blob/master/vendor/github.com/json-iterator/go/adapter.go
Apache-2.0
func Get(data []byte, path ...interface{}) Any { return ConfigDefault.Get(data, path...) }
Get quick method to get value from deeply nested JSON structure
Get
go
k8snetworkplumbingwg/multus-cni
vendor/github.com/json-iterator/go/adapter.go
https://github.com/k8snetworkplumbingwg/multus-cni/blob/master/vendor/github.com/json-iterator/go/adapter.go
Apache-2.0
func Marshal(v interface{}) ([]byte, error) { return ConfigDefault.Marshal(v) }
Marshal adapts to json/encoding Marshal API Marshal returns the JSON encoding of v, adapts to json/encoding Marshal API Refer to https://godoc.org/encoding/json#Marshal for more information
Marshal
go
k8snetworkplumbingwg/multus-cni
vendor/github.com/json-iterator/go/adapter.go
https://github.com/k8snetworkplumbingwg/multus-cni/blob/master/vendor/github.com/json-iterator/go/adapter.go
Apache-2.0
func MarshalIndent(v interface{}, prefix, indent string) ([]byte, error) { return ConfigDefault.MarshalIndent(v, prefix, indent) }
MarshalIndent same as json.MarshalIndent. Prefix is not supported.
MarshalIndent
go
k8snetworkplumbingwg/multus-cni
vendor/github.com/json-iterator/go/adapter.go
https://github.com/k8snetworkplumbingwg/multus-cni/blob/master/vendor/github.com/json-iterator/go/adapter.go
Apache-2.0
func MarshalToString(v interface{}) (string, error) { return ConfigDefault.MarshalToString(v) }
MarshalToString convenient method to write as string instead of []byte
MarshalToString
go
k8snetworkplumbingwg/multus-cni
vendor/github.com/json-iterator/go/adapter.go
https://github.com/k8snetworkplumbingwg/multus-cni/blob/master/vendor/github.com/json-iterator/go/adapter.go
Apache-2.0
func NewDecoder(reader io.Reader) *Decoder { return ConfigDefault.NewDecoder(reader) }
NewDecoder adapts to json/stream NewDecoder API. NewDecoder returns a new decoder that reads from r. Instead of a json/encoding Decoder, an Decoder is returned Refer to https://godoc.org/encoding/json#NewDecoder for more information
NewDecoder
go
k8snetworkplumbingwg/multus-cni
vendor/github.com/json-iterator/go/adapter.go
https://github.com/k8snetworkplumbingwg/multus-cni/blob/master/vendor/github.com/json-iterator/go/adapter.go
Apache-2.0
func (adapter *Decoder) Decode(obj interface{}) error { if adapter.iter.head == adapter.iter.tail && adapter.iter.reader != nil { if !adapter.iter.loadMore() { return io.EOF } } adapter.iter.ReadVal(obj) err := adapter.iter.Error if err == io.EOF { return nil } return adapter.iter.Error }
Decode decode JSON into interface{}
Decode
go
k8snetworkplumbingwg/multus-cni
vendor/github.com/json-iterator/go/adapter.go
https://github.com/k8snetworkplumbingwg/multus-cni/blob/master/vendor/github.com/json-iterator/go/adapter.go
Apache-2.0
func (adapter *Decoder) Buffered() io.Reader { remaining := adapter.iter.buf[adapter.iter.head:adapter.iter.tail] return bytes.NewReader(remaining) }
Buffered remaining buffer
Buffered
go
k8snetworkplumbingwg/multus-cni
vendor/github.com/json-iterator/go/adapter.go
https://github.com/k8snetworkplumbingwg/multus-cni/blob/master/vendor/github.com/json-iterator/go/adapter.go
Apache-2.0
func (adapter *Decoder) UseNumber() { cfg := adapter.iter.cfg.configBeforeFrozen cfg.UseNumber = true adapter.iter.cfg = cfg.frozeWithCacheReuse(adapter.iter.cfg.extraExtensions) }
UseNumber causes the Decoder to unmarshal a number into an interface{} as a Number instead of as a float64.
UseNumber
go
k8snetworkplumbingwg/multus-cni
vendor/github.com/json-iterator/go/adapter.go
https://github.com/k8snetworkplumbingwg/multus-cni/blob/master/vendor/github.com/json-iterator/go/adapter.go
Apache-2.0
func (adapter *Decoder) DisallowUnknownFields() { cfg := adapter.iter.cfg.configBeforeFrozen cfg.DisallowUnknownFields = true adapter.iter.cfg = cfg.frozeWithCacheReuse(adapter.iter.cfg.extraExtensions) }
DisallowUnknownFields causes the Decoder to return an error when the destination is a struct and the input contains object keys which do not match any non-ignored, exported fields in the destination.
DisallowUnknownFields
go
k8snetworkplumbingwg/multus-cni
vendor/github.com/json-iterator/go/adapter.go
https://github.com/k8snetworkplumbingwg/multus-cni/blob/master/vendor/github.com/json-iterator/go/adapter.go
Apache-2.0
func NewEncoder(writer io.Writer) *Encoder { return ConfigDefault.NewEncoder(writer) }
NewEncoder same as json.NewEncoder
NewEncoder
go
k8snetworkplumbingwg/multus-cni
vendor/github.com/json-iterator/go/adapter.go
https://github.com/k8snetworkplumbingwg/multus-cni/blob/master/vendor/github.com/json-iterator/go/adapter.go
Apache-2.0
func (adapter *Encoder) Encode(val interface{}) error { adapter.stream.WriteVal(val) adapter.stream.WriteRaw("\n") adapter.stream.Flush() return adapter.stream.Error }
Encode encode interface{} as JSON to io.Writer
Encode
go
k8snetworkplumbingwg/multus-cni
vendor/github.com/json-iterator/go/adapter.go
https://github.com/k8snetworkplumbingwg/multus-cni/blob/master/vendor/github.com/json-iterator/go/adapter.go
Apache-2.0
func (adapter *Encoder) SetIndent(prefix, indent string) { config := adapter.stream.cfg.configBeforeFrozen config.IndentionStep = len(indent) adapter.stream.cfg = config.frozeWithCacheReuse(adapter.stream.cfg.extraExtensions) }
SetIndent set the indention. Prefix is not supported
SetIndent
go
k8snetworkplumbingwg/multus-cni
vendor/github.com/json-iterator/go/adapter.go
https://github.com/k8snetworkplumbingwg/multus-cni/blob/master/vendor/github.com/json-iterator/go/adapter.go
Apache-2.0
func (adapter *Encoder) SetEscapeHTML(escapeHTML bool) { config := adapter.stream.cfg.configBeforeFrozen config.EscapeHTML = escapeHTML adapter.stream.cfg = config.frozeWithCacheReuse(adapter.stream.cfg.extraExtensions) }
SetEscapeHTML escape html by default, set to false to disable
SetEscapeHTML
go
k8snetworkplumbingwg/multus-cni
vendor/github.com/json-iterator/go/adapter.go
https://github.com/k8snetworkplumbingwg/multus-cni/blob/master/vendor/github.com/json-iterator/go/adapter.go
Apache-2.0
func Valid(data []byte) bool { return ConfigDefault.Valid(data) }
Valid reports whether data is a valid JSON encoding.
Valid
go
k8snetworkplumbingwg/multus-cni
vendor/github.com/json-iterator/go/adapter.go
https://github.com/k8snetworkplumbingwg/multus-cni/blob/master/vendor/github.com/json-iterator/go/adapter.go
Apache-2.0
func (stream *Stream) WriteFloat32(val float32) { if math.IsInf(float64(val), 0) || math.IsNaN(float64(val)) { stream.Error = fmt.Errorf("unsupported value: %f", val) return } abs := math.Abs(float64(val)) fmt := byte('f') // Note: Must use float32 comparisons for underlying float32 value to get precise cutoffs right. if abs != 0 { if float32(abs) < 1e-6 || float32(abs) >= 1e21 { fmt = 'e' } } stream.buf = strconv.AppendFloat(stream.buf, float64(val), fmt, -1, 32) }
WriteFloat32 write float32 to stream
WriteFloat32
go
k8snetworkplumbingwg/multus-cni
vendor/github.com/json-iterator/go/stream_float.go
https://github.com/k8snetworkplumbingwg/multus-cni/blob/master/vendor/github.com/json-iterator/go/stream_float.go
Apache-2.0
func (stream *Stream) WriteFloat32Lossy(val float32) { if math.IsInf(float64(val), 0) || math.IsNaN(float64(val)) { stream.Error = fmt.Errorf("unsupported value: %f", val) return } if val < 0 { stream.writeByte('-') val = -val } if val > 0x4ffffff { stream.WriteFloat32(val) return } precision := 6 exp := uint64(1000000) // 6 lval := uint64(float64(val)*float64(exp) + 0.5) stream.WriteUint64(lval / exp) fval := lval % exp if fval == 0 { return } stream.writeByte('.') for p := precision - 1; p > 0 && fval < pow10[p]; p-- { stream.writeByte('0') } stream.WriteUint64(fval) for stream.buf[len(stream.buf)-1] == '0' { stream.buf = stream.buf[:len(stream.buf)-1] } }
WriteFloat32Lossy write float32 to stream with ONLY 6 digits precision although much much faster
WriteFloat32Lossy
go
k8snetworkplumbingwg/multus-cni
vendor/github.com/json-iterator/go/stream_float.go
https://github.com/k8snetworkplumbingwg/multus-cni/blob/master/vendor/github.com/json-iterator/go/stream_float.go
Apache-2.0
func (stream *Stream) WriteFloat64(val float64) { if math.IsInf(val, 0) || math.IsNaN(val) { stream.Error = fmt.Errorf("unsupported value: %f", val) return } abs := math.Abs(val) fmt := byte('f') // Note: Must use float32 comparisons for underlying float32 value to get precise cutoffs right. if abs != 0 { if abs < 1e-6 || abs >= 1e21 { fmt = 'e' } } stream.buf = strconv.AppendFloat(stream.buf, float64(val), fmt, -1, 64) }
WriteFloat64 write float64 to stream
WriteFloat64
go
k8snetworkplumbingwg/multus-cni
vendor/github.com/json-iterator/go/stream_float.go
https://github.com/k8snetworkplumbingwg/multus-cni/blob/master/vendor/github.com/json-iterator/go/stream_float.go
Apache-2.0
func (stream *Stream) WriteFloat64Lossy(val float64) { if math.IsInf(val, 0) || math.IsNaN(val) { stream.Error = fmt.Errorf("unsupported value: %f", val) return } if val < 0 { stream.writeByte('-') val = -val } if val > 0x4ffffff { stream.WriteFloat64(val) return } precision := 6 exp := uint64(1000000) // 6 lval := uint64(val*float64(exp) + 0.5) stream.WriteUint64(lval / exp) fval := lval % exp if fval == 0 { return } stream.writeByte('.') for p := precision - 1; p > 0 && fval < pow10[p]; p-- { stream.writeByte('0') } stream.WriteUint64(fval) for stream.buf[len(stream.buf)-1] == '0' { stream.buf = stream.buf[:len(stream.buf)-1] } }
WriteFloat64Lossy write float64 to stream with ONLY 6 digits precision although much much faster
WriteFloat64Lossy
go
k8snetworkplumbingwg/multus-cni
vendor/github.com/json-iterator/go/stream_float.go
https://github.com/k8snetworkplumbingwg/multus-cni/blob/master/vendor/github.com/json-iterator/go/stream_float.go
Apache-2.0
func (n Number) String() string { return string(n) }
String returns the literal text of the number.
String
go
k8snetworkplumbingwg/multus-cni
vendor/github.com/json-iterator/go/reflect_json_number.go
https://github.com/k8snetworkplumbingwg/multus-cni/blob/master/vendor/github.com/json-iterator/go/reflect_json_number.go
Apache-2.0
func (n Number) Float64() (float64, error) { return strconv.ParseFloat(string(n), 64) }
Float64 returns the number as a float64.
Float64
go
k8snetworkplumbingwg/multus-cni
vendor/github.com/json-iterator/go/reflect_json_number.go
https://github.com/k8snetworkplumbingwg/multus-cni/blob/master/vendor/github.com/json-iterator/go/reflect_json_number.go
Apache-2.0
func (n Number) Int64() (int64, error) { return strconv.ParseInt(string(n), 10, 64) }
Int64 returns the number as an int64.
Int64
go
k8snetworkplumbingwg/multus-cni
vendor/github.com/json-iterator/go/reflect_json_number.go
https://github.com/k8snetworkplumbingwg/multus-cni/blob/master/vendor/github.com/json-iterator/go/reflect_json_number.go
Apache-2.0
func Sum64String(s string) uint64 { return Sum64([]byte(s)) }
Sum64String computes the 64-bit xxHash digest of s.
Sum64String
go
k8snetworkplumbingwg/multus-cni
vendor/github.com/cespare/xxhash/v2/xxhash_safe.go
https://github.com/k8snetworkplumbingwg/multus-cni/blob/master/vendor/github.com/cespare/xxhash/v2/xxhash_safe.go
Apache-2.0
func (d *Digest) WriteString(s string) (n int, err error) { return d.Write([]byte(s)) }
WriteString adds more data to d. It always returns len(s), nil.
WriteString
go
k8snetworkplumbingwg/multus-cni
vendor/github.com/cespare/xxhash/v2/xxhash_safe.go
https://github.com/k8snetworkplumbingwg/multus-cni/blob/master/vendor/github.com/cespare/xxhash/v2/xxhash_safe.go
Apache-2.0
func Sum64String(s string) uint64 { b := *(*[]byte)(unsafe.Pointer(&sliceHeader{s, len(s)})) return Sum64(b) }
Sum64String computes the 64-bit xxHash digest of s. It may be faster than Sum64([]byte(s)) by avoiding a copy.
Sum64String
go
k8snetworkplumbingwg/multus-cni
vendor/github.com/cespare/xxhash/v2/xxhash_unsafe.go
https://github.com/k8snetworkplumbingwg/multus-cni/blob/master/vendor/github.com/cespare/xxhash/v2/xxhash_unsafe.go
Apache-2.0