Categorygithub.com/flashbots/go-utils
module
0.6.0
Repository: https://github.com/flashbots/go-utils.git
Documentation: pkg.go.dev

# README

go-utils

Test status

Various reusable Go utilities and modules

cli

Various minor command-line interface helpers: cli.go

httplogger

Logging middleware for HTTP requests using go-ethereum/log.

See examples/httplogger/main.go

Install:

go get github.com/flashbots/go-utils/httplogger

Use:

mux := http.NewServeMux()
mux.HandleFunc("/v1/hello", HelloHandler)
loggedRouter := httplogger.LoggingMiddleware(r)

jsonrpc

Minimal JSON-RPC client implementation.

blocksub

Subscribe for new Ethereum block headers by polling and/or websocket subscription

See examples/blocksub/main.go and examples/blocksub/multisub.go

Install:

go get github.com/flashbots/go-utils/blocksub

Use:

blocksub := blocksub.NewBlockSub(context.Background(), httpURI, wsURI)
if err := blocksub.Start(); err != nil {
    panic(err)
}

// Subscribe to new headers
sub := blocksub.Subscribe(context.Background())
for header := range sub.C {
    fmt.Println("new header", header.Number.Uint64(), header.Hash().Hex())
}

# Packages

Package blocksub implements an Ethereum block subscriber that works with polling and/or websockets.
Package cli implements various reusable utility functions for command-line interfaces.
Package envflag is a wrapper for stdlib's flag that adds the environment variables as additional source of the values for flags.
No description provided by the author
Package httplogger implements a middleware that logs the incoming HTTP request & its duration using go-ethereum-log or logrus.
Package jsonrpc is a minimal JSON-RPC implementation.
Package logutils implements helpers for logging.
Package truthy implements helpers to test the truthy-ness of the values.