Skip to content

Commit

Permalink
[doc] Update acknowledgement
Browse files Browse the repository at this point in the history
  • Loading branch information
at15 committed Feb 25, 2018
1 parent d6aae98 commit 9dd1c2c
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 11 deletions.
42 changes: 32 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,14 @@ Gommon is a collection of common util libraries written in Go.

It has the following components:

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

Legacy

Expand Down Expand Up @@ -68,25 +69,46 @@ Currently, gommon is in a very violate state, please open issues after it become
Gommon is inspired by the following awesome libraries, most gommon packages have much less features and a few improvements
compared to packages it modeled after.

log

- [sirupsen/logrus](https://github.com/sirupsen/logrus) for structured logging
- log v1 is entirely modeled after logrus, entry contains log information with methods like `Info`, `Infof`
- [apex/log](https://github.com/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](https://github.com/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

config

- [spf13/cast](https://github.com/spf13/cast) for cast, it is used by Viper
- [spf13/viper](https://github.com/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

- [Requests](http://docs.python-requests.org/en/master/) for requests
- [hashicorp/go-cleanhttp](https://github.com/hashicorp/go-cleanhttp) for using non default http transport and client

generator

- [benbjohnson/tmpl](https://github.com/benbjohnson/tmpl) for go template generator
- first saw it in [influxdata/influxdb](https://github.com/influxdata/influxdb/blob/master/tsdb/engine/tsm1/encoding.gen.go.tmpl)
- we put template data in `gommon.yml`, so we don't need to pass data as json via cli
- [GeertJohan/go.rice](https://github.com/GeertJohan/go.rice) for ~~rice~~ noodle

noodle

- [GeertJohan/go.rice](https://github.com/GeertJohan/go.rice)
- we implemented `.gitignore` like [feature](https://github.com/at15/go.rice/issues/1) but the upstream didn't respond for the [feature request #83](https://github.com/GeertJohan/go.rice/issues/83)
- [pkg/errors](https://github.com/pkg/errors) for errors, it can not introduce breaking change, but `WithMessage` and `WithStack` is annoying

errors

- [pkg/errors](https://github.com/pkg/errors) it can not introduce breaking change, but `WithMessage` and `WithStack` is annoying
- see [#54](https://github.com/dyweb/gommon/issues/54) and [errors/doc](errors/doc) about other error packages

- https://github.com/pkg/errors/pull/122 for check existing stack before attach new one
- [uber-go/multierr#21]( https://github.com/uber-go/multierr/issues/21) for return bool after append
- [hashicorp/go-multierror](https://github.com/hashicorp/go-multierror) for `ErrorOrNil`

## About

It was part of [Ayi](https://github.com/dyweb/Ayi) and split out for wider use.
Expand Down
3 changes: 3 additions & 0 deletions errors/errors_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@ func wrappedStdErr() error {
func TestWrap(t *testing.T) {
assert := asst.New(t)

n := Wrap(nil, "nothing")
assert.Nil(n)

errw := Wrap(os.ErrClosed, "can't open closed file")
terr, ok := errw.(TracedError)
assert.True(ok)
Expand Down
3 changes: 2 additions & 1 deletion errors/multi.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,10 @@ import (

type MultiErr interface {
error
// Append returns true if the appended error is not nil, it is inspired by https://github.com/uber-go/multierr/issues/21
// Append returns true if the appended error is not nil, inspired by https://github.com/uber-go/multierr/issues/21
Append(error) bool
Errors() []error
// Error returns itself or nil if there are no errors, inspired by https://github.com/hashicorp/go-multierror
ErrorOrNil() error
// HasError is ErrorOrNil != nil
HasError() bool
Expand Down

0 comments on commit 9dd1c2c

Please sign in to comment.