You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
[errors] Replace pkg/errors Fix#54
- multi error and wrap error
- multi error `Append(err error)` returns true if it got a non nil error uber-go/multierr#21
- `Wrap` would reuse stack if the underlying error has one pkg/errors#122, and if `Frames()` is not called, `runtime.Frames` would not be expanded to `[]runtime.Frame`
Copy file name to clipboardExpand all lines: README.md
+38-12Lines changed: 38 additions & 12 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -10,13 +10,14 @@ Gommon is a collection of common util libraries written in Go.
10
10
11
11
It has the following components:
12
12
13
-
-[Config](config) A YAML config reader with template support
14
-
-[Log](log) A Javaish logger for Go, application can control library and set level for different pkg via config or flag
15
-
-[Generator](generator) Render go template, generate methods for logger interface based on `gommon.yml`
16
-
-[Noodle](noodle) Embed static assets for web application with `.noodleignore` support
17
-
-[Requests](requests) A pythonic wrapper for `net/http`, HTTP for Gopher.
18
-
-[Cast](cast) Convert Golang types
19
-
-[Data structure](structure) Bring Set etc. to Golang.
13
+
-[config](config) A YAML config reader with template support
14
+
-[errors](errors) Wrap error and multi error
15
+
-[generator](generator) Render go template, generate methods for logger interface based on `gommon.yml`
16
+
-[log](log) A Javaish logger for Go, application can control library and set level for different pkg via config or flag
17
+
-[noodle](noodle) Embed static assets for web application with `.noodleignore` support
18
+
-[requests](requests) A pythonic wrapper for `net/http`, HTTP for Gopher.
19
+
-[cast](cast) Convert Golang types
20
+
-[structure](structure) Bring data structure like Set etc. to Golang.
20
21
21
22
Legacy
22
23
@@ -26,16 +27,18 @@ Legacy
26
27
27
28
## Dependencies
28
29
29
-
Currently we only have two non standard library dependencies, see [Gopkg.lock](Gopkg.lock),
30
-
we might replace them with our own implementation in the future.
30
+
Currently we only have one non standard library dependencies, see [Gopkg.lock](Gopkg.lock)
31
31
32
-
-[pkg/errors](https://github.com/pkg/errors) for including context in error
33
-
- however it's still not very machine friendly, we are likely to opt it out in future version
34
32
-[go-yaml/yaml](https://github.com/go-yaml/yaml) for read config written in YAML
35
33
- 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).
36
34
- might write one in [ANTLR](https://github.com/antlr/antlr4)
37
35
- we also have a DSL work in progress [RCL: Reika Configuration Language](https://github.com/at15/reika/issues/49), which is like [HCL](https://github.com/hashicorp/hcl2)
38
36
37
+
Removed
38
+
39
+
-[pkg/errors](https://github.com/pkg/errors) for including context in error
40
+
- removed in [#59](https://github.com/dyweb/gommon/pull/59)
41
+
39
42
<!-- no, we are using the standard flag package ... -->
40
43
<!-- For command line util, we are using [spf13/cobra](https://github.com/spf13/cobra), it is more flexible than [ufrave/cli](https://github.com/urfave/cli) -->
41
44
@@ -66,23 +69,46 @@ Currently, gommon is in a very violate state, please open issues after it become
66
69
Gommon is inspired by the following awesome libraries, most gommon packages have much less features and a few improvements
67
70
compared to packages it modeled after.
68
71
72
+
log
73
+
69
74
-[sirupsen/logrus](https://github.com/sirupsen/logrus) for structured logging
70
75
- log v1 is entirely modeled after logrus, entry contains log information with methods like `Info`, `Infof`
71
76
-[apex/log](https://github.com/apex/log) for log handlers
72
77
- 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
73
78
-[uber-go/zap](https://github.com/uber-go/zap) for serialize log fields without using `fmt.Sprintf` and use `strconv` directly
74
79
- we didn't go that extreme as Zap or ZeroLog for zero allocation, performance is not our goal for now
80
+
81
+
config
82
+
75
83
-[spf13/cast](https://github.com/spf13/cast) for cast, it is used by Viper
76
84
-[spf13/viper](https://github.com/spf13/viper/) for config
77
85
- looking up config via string key makes type system useless, so we always marshal entire config file to a single struct
78
86
- it also makes refactor easier
87
+
88
+
requests
89
+
79
90
-[Requests](http://docs.python-requests.org/en/master/) for requests
91
+
-[hashicorp/go-cleanhttp](https://github.com/hashicorp/go-cleanhttp) for using non default http transport and client
92
+
93
+
generator
94
+
80
95
-[benbjohnson/tmpl](https://github.com/benbjohnson/tmpl) for go template generator
81
96
- first saw it in [influxdata/influxdb](https://github.com/influxdata/influxdb/blob/master/tsdb/engine/tsm1/encoding.gen.go.tmpl)
82
97
- we put template data in `gommon.yml`, so we don't need to pass data as json via cli
83
-
-[GeertJohan/go.rice](https://github.com/GeertJohan/go.rice) for ~~rice~~ noodle
- 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)
85
103
104
+
errors
105
+
106
+
-[pkg/errors](https://github.com/pkg/errors) it can not introduce breaking change, but `WithMessage` and `WithStack` is annoying
107
+
- see [#54](https://github.com/dyweb/gommon/issues/54) and [errors/doc](errors/doc) about other error packages
108
+
-https://github.com/pkg/errors/pull/122 for check existing stack before attach new one
109
+
-[uber-go/multierr#21](https://github.com/uber-go/multierr/issues/21) for return bool after append
110
+
-[hashicorp/go-multierror](https://github.com/hashicorp/go-multierror) for `ErrorOrNil`
111
+
86
112
## About
87
113
88
114
It was part of [Ayi](https://github.com/dyweb/Ayi) and split out for wider use.
0 commit comments