date format

This commit is contained in:
solar
2019-03-05 17:34:54 +08:00
parent 1d9c4896c8
commit 33c0a0dfe4
3 changed files with 10 additions and 10 deletions

View File

@@ -10,9 +10,9 @@ import (
hp "github.com/40t/go-sniffer/plugSrc/http/build" hp "github.com/40t/go-sniffer/plugSrc/http/build"
mongodb "github.com/40t/go-sniffer/plugSrc/mongodb/build" mongodb "github.com/40t/go-sniffer/plugSrc/mongodb/build"
mysql "github.com/40t/go-sniffer/plugSrc/mysql/build"
redis "github.com/40t/go-sniffer/plugSrc/redis/build" redis "github.com/40t/go-sniffer/plugSrc/redis/build"
mssql "github.com/feiin/go-sniffer/plugSrc/mssql/build" mssql "github.com/feiin/go-sniffer/plugSrc/mssql/build"
mysql "github.com/feiin/go-sniffer/plugSrc/mysql/build"
"github.com/google/gopacket" "github.com/google/gopacket"
) )

View File

@@ -4,7 +4,7 @@ import "time"
func GetNowStr(isClient bool) string { func GetNowStr(isClient bool) string {
var msg string var msg string
msg += time.Now().Format("2006-01-02 15:04:05") msg += time.Now().Format("2006-01-02 15:04:05.000")
if isClient { if isClient {
msg += "| cli -> ser |" msg += "| cli -> ser |"
} else { } else {

View File

@@ -9,16 +9,16 @@ import (
func GetNowStr(isClient bool) string { func GetNowStr(isClient bool) string {
var msg string var msg string
msg += time.Now().Format("2006-01-02 15:04:05") msg += time.Now().Format("2006-01-02 15:04:05.000")
if isClient { if isClient {
msg += "| cli -> ser |" msg += "| cli -> ser |"
}else{ } else {
msg += "| ser -> cli |" msg += "| ser -> cli |"
} }
return msg return msg
} }
func ReadStringFromByte(b []byte) (string,int) { func ReadStringFromByte(b []byte) (string, int) {
var l int var l int
l = bytes.IndexByte(b, 0x00) l = bytes.IndexByte(b, 0x00)
@@ -35,18 +35,18 @@ func LengthBinary(b []byte) (uint32, int) {
return uint32(first), 1 return uint32(first), 1
} }
if first == 251 { if first == 251 {
return 0,1 return 0, 1
} }
if first == 252 { if first == 252 {
return binary.LittleEndian.Uint32(b[1:2]),1 return binary.LittleEndian.Uint32(b[1:2]), 1
} }
if first == 253 { if first == 253 {
return binary.LittleEndian.Uint32(b[1:4]),3 return binary.LittleEndian.Uint32(b[1:4]), 3
} }
if first == 254 { if first == 254 {
return binary.LittleEndian.Uint32(b[1:9]),8 return binary.LittleEndian.Uint32(b[1:9]), 8
} }
return 0,0 return 0, 0
} }
func LengthEncodedInt(input []byte) (num uint64, isNull bool, n int) { func LengthEncodedInt(input []byte) (num uint64, isNull bool, n int) {