Skip to content

sandwich-go/zapgen

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

zapencoder

封装Golang内置类型的slicemap结构,以便能够使用zap.Arrayzap.Object函数,防止zap使用反射进行序列化。

使用

import "github.com/sandwich-go/zapgen/zapencoder"
import "go.uber.org/zap"
import "testing"

func TestUint64StringMap(t *testing.T) {
    var a = make(map[uint64]string)
    a[1] = "a"
    a[2] = "b"
    t.Log(zap.Object("A", zapencoder.Uint64StringMap(a)))
	
    var b = make([]int64, 0, 2)
    b = append(b, 1)
    b = append(b, 2)
    t.Log(zap.Array("B", zapencoder.Int64Slice(b)))
}

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages