Skip to content

Commit 78b4da1

Browse files
authored
v2.0.0 release
2 parents c55f72d + d7a0d83 commit 78b4da1

File tree

13 files changed

+96
-108
lines changed

13 files changed

+96
-108
lines changed

doc.go

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
1-
/*
2-
Package std provides useful go interfaces for building consistent, testable,
3-
mockable packages.
4-
5-
Interfaces available in the standard library should be preferred over anything
6-
you find here.
7-
*/
1+
// Package std provides useful go interfaces for building consistent, testable,
2+
// mockable packages.
3+
//
4+
// Interfaces available in the standard library should be preferred over anything
5+
// you find here.
86
package std

error/caller.go

Lines changed: 0 additions & 10 deletions
This file was deleted.

error/error.go

Lines changed: 0 additions & 23 deletions
This file was deleted.

errors/caller.go

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
package error
2+
3+
// Caller defines an interface to runtime caller results.
4+
type Caller interface {
5+
// File returns the file in which the call occurred.
6+
File() string
7+
8+
// Func returns the name of the function in which the call occurred.
9+
Func() string
10+
11+
// Line returns the line number in the file in which the call occurred.
12+
Line() int
13+
14+
// Pc returns the program counter.
15+
Pc() uintptr
16+
17+
// Trace returns the call stack.
18+
Trace() Trace
19+
}

errors/error.go

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
package error
2+
3+
// Error defines a robust error stack interface.
4+
type Error interface {
5+
// Caller returns the associated Caller instance.
6+
Caller() Caller
7+
8+
// Error implements error.
9+
Error() string
10+
11+
// Has tests to see if the test error exists anywhere in the error
12+
// stack.
13+
Has(test error) bool
14+
15+
// Is tests to see if the test error matches most recent error in the
16+
// stack.
17+
Is(test error) bool
18+
19+
// Unwrap returns the next error, if any.
20+
Unwrap() Error
21+
}
Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,4 @@
11
package error
22

3-
// Code defines an error code type.
4-
type Code int
5-
63
// Trace defines an error trace.
74
type Trace []Caller

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
module github.com/bdlm/std
1+
module github.com/bdlm/std/v2
22

33
go 1.14

importer/importer.go

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,12 @@
11
package importer
22

3-
/*
4-
Importer is the interface that wraps the basic Import method.
5-
6-
Importer accepts the empty interface and extracts data from there, returning
7-
an error if the import fails.
8-
9-
Implementations must not retain data. Implementations should not retain any
10-
imported data if returning an error.
11-
*/
3+
// Importer is the interface that wraps the basic Import method.
4+
//
5+
// Importer accepts the empty interface and extracts data from there, returning
6+
// an error if the import fails.
7+
//
8+
// Implementations must not retain data. Implementations should not retain any
9+
// imported data if returning an error.
1210
type Importer interface {
1311
// Import imports the given data into the reciever's data structure.
1412
Import(data interface{}) error

iterator/iterator.go

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
package iterator
22

3-
/*
4-
Iterator defines a simple interator interface.
5-
*/
3+
// Iterator defines a simple interator interface.
64
type Iterator interface {
75
// Cur reads the key and value at the current cursor postion into pK and
86
// pV respectively. Cur will return false if no iteration has begun,

logger/logger.go

Lines changed: 26 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,31 @@
11
package logger
22

3-
/*
4-
Logger defines a common logger interface for packages that accept an
5-
injected logger. It fully implements the standard 'pkg/log' log package
6-
logging methods as well Info, Warn, Error, and Debug level equivalents.
7-
The Info* methods are expected to mirror the Print* methods.
8-
9-
Packages that implement this interface should support level codes and
10-
expect usage as follows:
11-
12-
- Panic, highest level of severity. Log and then call panic.
13-
- Fatal, log and then call `os.Exit(<code>)` with a non-zero value.
14-
- Error, used for errors that should definitely be noted and addressed.
15-
- Warn, non-critical information about undesirable behavior that needs
16-
to be addressed in some way.
17-
- Info, general operational information about what's happening inside an
18-
application. 'Print' methods should output Info-level information.
19-
- Debug, usually only enabled when debugging. Add anything useful, but
20-
still exclude PII or sensitive data...
21-
22-
Each level should include all the log levels above it. To manage the output,
23-
this interface also implements a SetLevel(level uint) method that defines
24-
the log level of this logger.
25-
26-
Compatible logger packages include:
27-
28-
- "github.com/bdlm/log"
29-
- "github.com/sirupsen/logrus"
30-
*/
3+
// Logger defines a common logger interface for packages that accept an
4+
// injected logger. It fully implements the standard 'pkg/log' log package
5+
// logging methods as well Info, Warn, Error, and Debug level equivalents.
6+
// The Info* methods are expected to mirror the Print* methods.
7+
//
8+
// Packages that implement this interface should support level codes and
9+
// expect usage as follows:
10+
//
11+
// - Panic, highest level of severity. Log and then call panic.
12+
// - Fatal, log and then call `os.Exit(<code>)` with a non-zero value.
13+
// - Error, used for errors that should definitely be noted and addressed.
14+
// - Warn, non-critical information about undesirable behavior that needs
15+
// to be addressed in some way.
16+
// - Info, general operational information about what's happening inside an
17+
// application. 'Print' methods should output Info-level information.
18+
// - Debug, usually only enabled when debugging. Add anything useful, but
19+
// still exclude PII or sensitive data...
20+
//
21+
// Each level should include all the log levels above it. To manage the output,
22+
// this interface also implements a SetLevel(level uint) method that defines
23+
// the log level of this logger.
24+
//
25+
// Compatible logger packages include:
26+
//
27+
// - "github.com/bdlm/log"
28+
// - "github.com/sirupsen/logrus"
3129
type Logger interface {
3230
// WithFields adds a map of key/value data to the log entry.
3331
WithFields(Fields)

0 commit comments

Comments
 (0)