gitee.com/lh-her-team/common@v1.5.1/birdsnest/utils.go (about) 1 // Package birdsnest utils 2 package birdsnest 3 4 import ( 5 "encoding/binary" 6 "time" 7 ) 8 9 // ToTimestampKeysAndNormalKeys string to TimestampKey return timestampKeys and normalKeys 10 func ToTimestampKeysAndNormalKeys(key []string) (timestampKeys []Key, normalKeys []Key) { 11 for i := 0; i < len(key); i++ { 12 timestampKey, err := ToTimestampKey(key[i]) 13 if err != nil { 14 normalKeys = append(normalKeys, TimestampKey(key[i])) 15 } else { 16 timestampKeys = append(timestampKeys, timestampKey) 17 } 18 } 19 return 20 } 21 22 // CurrentTimestampNano get current timestamp nanosecond 23 func CurrentTimestampNano() int64 { 24 return time.Now().UnixNano() 25 } 26 27 // bytes2nano bytes to nanosecond 28 func bytes2nano(b []byte) int64 { 29 return int64(binary.BigEndian.Uint64(b)) 30 }