Add dependency to your golang project:
go get github.com/ethanvc/evo
Import in your golang project:
import "github.com/ethanvc/evo"
Example: auto parse url param and body to request struct:
createUser := func(c context.Context, req *CreateUserReq)(*CreateUserResp, error){
...
}
svr := NewServer()
svr.POST("/api/users/:user_id", NewStdHandlerF(createUser))
Extend slog's function.
- trace id support.
- filed mask support. user can mark struct filed server.goand then log library will mask sensitive data for you.
Examples: mask sensitive field.
type Abc struct {
Name string `evolog:"ignore"`
}
abc := &Abc{Name: "test"}
slog.InfoContext(c, "MaskSensitiveField", slog.Any("abc", abc))
Some base utils commonly used:
- type safe SyncMap.
- error code based Status inspired from grpc. So you can just process limited and unified error codes.
Library to obtain cpu/memory and others resources in process perspective.
This Library will consider cgroup limit.