gommon

module
v0.0.4 Latest Latest
Warning

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

Go to latest
Published: Feb 21, 2018 License: MIT

README

Gommon - Golang common util 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
  • Log A Javaish logger for Go, application can control library and set level for different pkg via config or flag
  • Generator Render go template, generate methods for logger interface based on gommon.yml
  • Noodle Embed static assets for web application with .noodleignore support
  • Requests A pythonic wrapper for net/http, HTTP for Gopher.
  • Cast Convert Golang types
  • Data structure Bring Set etc. to Golang.
  • Runner A os/exec wrapper

Dependencies

Currently we only have two non standard library dependencies, see Gopkg.lock, we might replace them with our own implementation in the future.

  • pkg/errors for including context in error
    • however it's still not very machine friendly, we are likely to opt it out in future version
  • 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

Development

Roadmap
  • rice bind static assets
  • runner, simplify usage
  • config v2, better multi document support, deep merge var etc.
  • log v2 tree like, http logger, http handler for adjust logger

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 features a few improvements compared to packages it modeled after.

  • 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 our goal for now
  • 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
  • Requests for requests
  • benbjohnson/tmpl for go template generator
    • first saw it in influxdata/influxdb
    • we put template data in gommon.yml, so we don't need to pass it via cli
  • GeertJohan/go.rice for rice noodle

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.

Directories

Path Synopsis
Package cast convert types safely and drop incompatible types during conversion Ref https://github.com/spf13/cast
Package cast convert types safely and drop incompatible types during conversion Ref https://github.com/spf13/cast
cmd
gommon command
Package config support django syntax in yaml config Code generated by gommon from config/gommon.yml DO NOT EDIT.
Package config support django syntax in yaml config Code generated by gommon from config/gommon.yml DO NOT EDIT.
legacy
log
Package log can filter log by field and support multiple level
Package log can filter log by field and support multiple level
log
Code generated by gommon from log/gommon.yml DO NOT EDIT.
Code generated by gommon from log/gommon.yml DO NOT EDIT.
_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
playground
issue_noodle_50 command
Package requests is a pythonic HTTP library for Gopher Package requests wrap net/http like requests did for python it is easy to use, but not very efficient
Package requests is a pythonic HTTP library for Gopher Package requests wrap net/http like requests did for python it is easy to use, but not very efficient
Package runner run commands with some convention
Package runner run commands with some convention
Package structure add some missing common data structures to Golang
Package structure add some missing common data structures to Golang
Package util contains helper for test
Package util contains helper for test
color
Code generated by gommon from util/color/color_generated.go.tmpl DO NOT EDIT.
Code generated by gommon from util/color/color_generated.go.tmpl DO NOT EDIT.
hashutil
Package hashutil provides alloc free alternatives for pkg/hash
Package hashutil provides alloc free alternatives for pkg/hash

Jump to

Keyboard shortcuts

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