gommon

module
v0.0.6 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 4, 2018 License: MIT

README

Gommon - Go common libraries

GoDoc Build Status Go Report Card codebeat badge Sourcegraph

Gommon is a collection of common util libraries written in Go.

It has the following components:

  • config A YAML config reader with template support
  • errors Wrap error and multi error
  • generator Render go template, generate methods for logger interface based on gommon.yml
  • log A Javaish logger for Go, application can control library and set level for different pkg via config or flag
  • noodle Embed static assets for web application with .noodleignore support
  • requests A pythonic wrapper for net/http, HTTP for Gopher.
  • cast Convert Golang types
  • structure Bring data structure like Set etc. to Golang.

Legacy

  • log v1 A logrus like structured logger
  • Runner A os/exec wrapper

Dependencies

Currently we only have one non standard library dependencies, see Gopkg.lock

  • go-yaml/yaml for read config written in YAML
    • we don't need most feature of YAML, and want to have access to the parser directly to report which line has incorrect semantic (after checking it in application).
      • might write one in ANTLR
    • we also have a DSL work in progress RCL: Reika Configuration Language, which is like HCL

Removed

  • pkg/errors for including context in error
    • removed in #59
    • replaced by gommon/errors

Development

Roadmap

0.0.6

  • better documentation, add examples
  • explain internals of some implementation

0.0.7

  • organized error types
  • extension for collecting errors using third party services

0.0.8

  • tree of loggers in use
  • benchmark against other loggers
  • support better logging for errors

License

MIT

Contribution

Currently, gommon is in a very violate state, please open issues after it becomes stable

Acknowledgement & Improvement

Gommon is inspired by the following awesome libraries, most gommon packages have much less (not more) features and a few improvements compared to packages it modeled after.

log

  • sirupsen/logrus for structured logging
    • log v1 is entirely modeled after logrus, entry contains log information with methods like Info, Infof
  • apex/log for log handlers
    • log v2's handler is inspired by apex/log, but we didn't use entry and chose to pass multiple parameters to explicitly state what a handler should handle
  • uber-go/zap for serialize log fields without using fmt.Sprintf and use strconv directly
    • we didn't go that extreme as Zap or ZeroLog for zero allocation, performance is not measured

config

  • spf13/cast for cast, it is used by Viper
  • spf13/viper for config
    • looking up config via string key makes type system useless, so we always marshal entire config file to a single struct
      • it also makes refactor easier
    • we only use YAML, might add RCL, won't support TOML

requests

generator

noodle

errors

About

It was part of Ayi and split out for wider use. The name Gommon is suggested by @arrowrowe. The original blog post can be found here. Thanks all the fellows in @dyweb especially @gaocegege for their support in early development.

Directories

Path Synopsis
Package cast convert types safely and drop incompatible types during conversion it is inspired by https://github.com/spf13/cast
Package cast convert types safely and drop incompatible types during conversion it is inspired by https://github.com/spf13/cast
cmd
gommon command
gommon is the commandline util for generator
gommon is the commandline util for generator
Package config supports go text/template, environment and self defined variables
Package config supports go text/template, environment and self defined variables
Package errors provides multi error, error wrapping.
Package errors provides multi error, error wrapping.
Package generator render go template, call external commands, generate gommon specific methods based on gommon.yml
Package generator render go template, call external commands, generate gommon specific methods based on gommon.yml
Package legacy contains deprecated gommon packages
Package legacy contains deprecated gommon packages
log
Package log(Deprecated) can filter log by field and support multiple level
Package log(Deprecated) can filter log by field and support multiple level
runner
Package runner(Deprecated) run commands with some convention
Package runner(Deprecated) run commands with some convention
log
Package log provides structured logging with fine grained control over libraries using a tree hierarchy of loggers.
Package log provides structured logging with fine grained control over libraries using a tree hierarchy of loggers.
handlers/cli
Package cli writes is same as builtin IOHandler except color and delta time.
Package cli writes is same as builtin IOHandler except color and delta time.
handlers/json
Package json writes log in JSON format, it concatenates string directly and does not use encoding/json.
Package json writes log in JSON format, it concatenates string directly and does not use encoding/json.
Package noodle helps embedding static assets into go binary, it supports using ignore file
Package noodle helps embedding static assets into go binary, it supports using ignore file
_examples/embed command
_examples/embed/gen
Code generated by gommon from config/gommon.yml DO NOT EDIT.
Code generated by gommon from config/gommon.yml DO NOT EDIT.
_examples/local command
Package playground is used for testing out issues and language features
Package playground is used for testing out issues and language features
issue_noodle_50 command
for i, ele := range slice is reusing same struct https://github.com/dyweb/gommon/issues/50
for i, ele := range slice is reusing same struct https://github.com/dyweb/gommon/issues/50
Package requests is a wrapper around net/http with less public global variables Package requests wrap net/http like requests did for python it is easy to use, but not very efficient
Package requests is a wrapper around net/http with less public global variables Package requests wrap net/http like requests did for python it is easy to use, but not very efficient
Package structure add some missing common data structures to Golang
Package structure add some missing common data structures to Golang
Package util contains helpers
Package util contains helpers
color
Package color defines color code for pretty print in linux shell, windows is not supported
Package color defines color code for pretty print in linux shell, windows is not supported
fsutil
Package fsutil adds ignore support for walk
Package fsutil adds ignore support for walk
hashutil
Package hashutil provides alloc free alternatives for pkg/hash
Package hashutil provides alloc free alternatives for pkg/hash
logutil
Package logutil is a registry of loggers, it is required for all lib and app that use gommon/log.
Package logutil is a registry of loggers, it is required for all lib and app that use gommon/log.
runtimeutil
Package runtimeutil provides wrapper to get caller, stack etc.
Package runtimeutil provides wrapper to get caller, stack etc.
testutil
Package testutil defines helper functions that fails test instead of return error
Package testutil defines helper functions that fails test instead of return error

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL