util

package
v0.0.0-...-7b3ddb2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 11, 2019 License: Apache-2.0 Imports: 17 Imported by: 0

Documentation

Overview

Copyright 2016 PingCAP, Inc. Modified work copyright (C) 2019 The Vearch Authors.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, See the License for the specific language governing permissions and limitations under the License.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreedto in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Index

Constants

View Source
const (
	HeaderAuthBasic = "Basic "
)
View Source
const ShiftStartFlag byte = 0x20

Variables

This section is empty.

Functions

func AssembleMap

func AssembleMap(maps map[string]interface{}, split string) map[string]interface{}

make map to level 1 example map[a.b]=1 it will map[a][b]=1

func AuthDecrypt

func AuthDecrypt(headerData string) (userName, password string, err error)

func AuthEncrypt

func AuthEncrypt(userName, password string) string

func BuildAddr

func BuildAddr(ip string, port uint16) string

func BuildAddrBothString

func BuildAddrBothString(ip string, port string) string

func BytesPrefix

func BytesPrefix(prefix []byte) ([]byte, []byte)

func BytesToUint32

func BytesToUint32(b []byte) uint32

func BytesToUint64

func BytesToUint64(b []byte) uint64

func DrawMap

func DrawMap(maps map[string]interface{}, split string) map[string]interface{}

make map to level 1 example map[a][b]=1 it wil map[a.b]=1

func Float64ToInt64

func Float64ToInt64(f float64) int64

func GetIpFromContext

func GetIpFromContext(ctx context.Context) string

func GetLocalIps

func GetLocalIps() []string

func GetOrDefault

func GetOrDefault(mapinterface *map[string]interface{}, k string, dv interface{}) interface{}

func Int64ToFloat64

func Int64ToFloat64(i int64) float64

func IsNum

func IsNum(s string) bool

func MapContains

func MapContains(m map[string]interface{}, key string) bool

is key in map

func MergeMap

func MergeMap(dest, src map[string]interface{})

* deep merge src to dest

func Normalization

func Normalization(feature []float32) error

func P2Bool

func P2Bool(v *bool) bool

func P2Float32

func P2Float32(v *float32) float32

func P2Float64

func P2Float64(v *float64) float64

func P2Int

func P2Int(v *int) int

func P2Int16

func P2Int16(v *int16) int16

func P2Int32

func P2Int32(v *int32) int32

func P2Int64

func P2Int64(v *int64) int64

func P2Int8

func P2Int8(v *int8) int8

func P2Rune

func P2Rune(v *rune) rune

func P2Str

func P2Str(v *string) string

all point to value

func PBool

func PBool(v bool) *bool

func PFloat32

func PFloat32(v float32) *float32

func PFloat64

func PFloat64(v float64) *float64

func PInt

func PInt(v int) *int

func PInt16

func PInt16(v int16) *int16

func PInt32

func PInt32(v int32) *int32

func PInt64

func PInt64(v int64) *int64

func PInt8

func PInt8(v int8) *int8

func PRune

func PRune(v rune) *rune

func PStr

func PStr(v string) *string

change object to pointer

func ParseAddr

func ParseAddr(addr string) []string

func SliceToString

func SliceToString(b []byte) (s string)

SliceToString slice to string with out data copy

func SlotSplit

func SlotSplit(start, end uint32, n uint64) []uint32

func StringToSlice

func StringToSlice(s string) (b []byte)

StringToSlice string to slice with out data copy

func Uint32ToBytes

func Uint32ToBytes(v uint32) []byte

func Uint64ToBytes

func Uint64ToBytes(v uint64) []byte

func WriteWithBufio

func WriteWithBufio(name, content string) error

Types

type Duration

type Duration struct {
	time.Duration
}

Duration is a wrapper of time.Duration for TOML and JSON.

func NewDuration

func NewDuration(duration time.Duration) Duration

NewDuration creates a Duration from time.Duration.

func (*Duration) MarshalJSON

func (d *Duration) MarshalJSON() ([]byte, error)

MarshalJSON returns the duration as a JSON string.

func (*Duration) UnmarshalJSON

func (d *Duration) UnmarshalJSON(text []byte) error

UnmarshalJSON parses a JSON string into the duration.

func (*Duration) UnmarshalText

func (d *Duration) UnmarshalText(text []byte) error

UnmarshalText parses a TOML string into the duration.

type Value

type Value []byte

func NewPrefixCodedInt64

func NewPrefixCodedInt64(in int64, shift uint) (Value, error)

func PrefixCodedFloat64

func PrefixCodedFloat64(float float64, shift uint) Value

func PrefixCodedInt64

func PrefixCodedInt64(in int64, shift uint) Value

func (Value) Float64

func (p Value) Float64() (float64, error)

func (Value) Int64

func (p Value) Int64() (int64, error)

func (Value) Shift

func (p Value) Shift() (uint, error)

Directories

Path Synopsis
Package ioutil2 provides extra functionality along similar lines to io/ioutil.
Package ioutil2 provides extra functionality along similar lines to io/ioutil.
Package metrics is a generated protocol buffer package.
Package metrics is a generated protocol buffer package.
runtime
os
server
rpc
Package glog implements logging analogous to the Google-internal C++ INFO/ERROR/V setup.
Package glog implements logging analogous to the Google-internal C++ INFO/ERROR/V setup.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL