Documentation ¶
Overview ¶
Copyright 2014 loolgame Author. All Rights Reserved.
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, 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
- func BoolToBytes(v bool) []byte
- func BytesToBool(buf []byte) bool
- func BytesToFloat32(bytes []byte) float32
- func BytesToFloat64(bytes []byte) float64
- func BytesToInt(buf []byte) int
- func BytesToInt32(buf []byte) int32
- func BytesToInt64(buf []byte) int64
- func BytesToMap(bytes []byte) (map[string]interface{}, error)
- func BytesToMapString(bytes []byte) (map[string]string, error)
- func Float32ToBytes(float float32) []byte
- func Float64ToBytes(float float64) []byte
- func Int32ToBytes(i int32) []byte
- func Int64ToBytes(i int64) []byte
- func IntToBytes(i int) []byte
- func InterfaceToBytes(jmap interface{}) ([]byte, error)
- func MapToBytes(jmap map[string]interface{}) ([]byte, error)
- func MapToBytesString(jmap map[string]string) ([]byte, error)
- func RecoverFunc()
- type ID
Constants ¶
const Nano2Millisecond int64 = 1000000
Variables ¶
This section is empty.
Functions ¶
func BoolToBytes ¶
func BytesToBool ¶
func BytesToFloat32 ¶
func BytesToFloat64 ¶
func BytesToInt ¶
func BytesToInt32 ¶
func BytesToInt64 ¶
func BytesToMap ¶
func Float32ToBytes ¶
func Float64ToBytes ¶
func Int32ToBytes ¶
func Int64ToBytes ¶
func IntToBytes ¶
func InterfaceToBytes ¶
func MapToBytes ¶
func RecoverFunc ¶
func RecoverFunc()
Types ¶
type ID ¶
type ID uint64
An ID is a unique, uniformly distributed 64-bit ID.
func GenerateID ¶
func GenerateID() ID
generateID returns a randomly-generated 64-bit ID. This function is thread-safe. IDs are produced by consuming an AES-CTR-128 keystream in 64-bit chunks. The AES key is randomly generated on initialization, as is the counter's initial state. On machines with AES-NI support, ID generation takes ~30ns and generates no garbage.
func (ID) MarshalJSON ¶
MarshalJSON encodes the ID as a hex string.
func (*ID) UnmarshalJSON ¶
UnmarshalJSON decodes the given data as either a hexadecimal string or JSON integer.