Skip to content

devboxhq/go-utils

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

14 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Go Utils

Utilities and packages containing helpful code!

List of packages:

  • Path related (util)
  • Serialization (util)
  • GRPC Middleware (grpc/middleware)
  • JWT Auth (auth/jwt)

Installation

go get -u github.com/devboxhq/go-utils

Examples

  • get root path based on relative path
import "github.com/devboxhq/go-utils/pkg/util"

func main() {
    path := util.FromRootPath("binaries")
}
  • json to bytes
import "github.com/devboxhq/go-utils/pkg/util"

func main() {
    data := util.MustJsonToBytes(jsonData)
}
  • GRPC zap middleware
import (
    "github.com/devboxhq/go-utils/pkg/grpc/middleware"
    "go.uber.org/zap"
    "google.golang.org/grpc"
)

func main() {
    logger, _ := zap.NewProduction()

    // create manager and add zap middleware
    manager := middleware.Manager{}
    _ = manager.AddMiddleware(middleware.NewZapMiddleware())

    // provide middlewares to GRPC server
    grpcServer := grpc.NewServer(manager.BuildServerOptions()...)
}

About

Utilities and Packages for go codebase

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages