Skip to content

Commit ca4ed15

Browse files
committed
Pass golint
Closes #5
1 parent bec65b5 commit ca4ed15

File tree

4 files changed

+19
-2
lines changed

4 files changed

+19
-2
lines changed

ci/lint.sh

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,5 +7,4 @@ cd "$(git rev-parse --show-toplevel)"
77
# shellcheck disable=SC2046
88
shellcheck -x $(git ls-files "*.sh")
99
go vet ./...
10-
# Re enable later.
11-
#go run golang.org/x/lint/golint -set_exit_status ./...
10+
go run golang.org/x/lint/golint -set_exit_status ./...

internal/skipctx/skipctx.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,14 @@ import (
99

1010
type skipKey struct{}
1111

12+
// With appends to the skip offset in the context and returns
13+
// a new context with the new skip offset.
1214
func With(ctx context.Context, skip int) context.Context {
1315
skip += From(ctx)
1416
return context.WithValue(ctx, skipKey{}, skip)
1517
}
1618

19+
// From returns the skip offset.
1720
func From(ctx context.Context) int {
1821
l, _ := ctx.Value(skipKey{}).(int)
1922
return l

slog.go

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import (
44
"context"
55
)
66

7+
// Logger is the core interface for logging.
78
type Logger interface {
89
// Debug means a potentially noisy log.
910
Debug(ctx context.Context, msg string, fields ...Field)
@@ -31,17 +32,26 @@ type field struct {
3132
value fieldValue
3233
}
3334

35+
// Field represents a log field.
3436
type Field interface {
3537
LogKey() string
3638
Value
3739
}
3840

41+
// Value represents a log value.
42+
// The value returned will be logged.
43+
// Your own types can implement this interface to
44+
// override their logging appearance.
3945
type Value interface {
4046
LogValue() interface{}
4147
}
4248

49+
// ValueFunc is a function that computes its logging
50+
// representation. Use it to override the logging
51+
// representation of a structure inline.
4352
type ValueFunc func() interface{}
4453

54+
// LogValue implements Value.
4555
func (fn ValueFunc) LogValue() interface{} {
4656
return fn()
4757
}

test.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,15 @@ import (
55
"testing"
66
)
77

8+
// TestOptions represents the options for the logger returned
9+
// by Test.
810
type TestOptions struct {
11+
// IgnoreErrors causes the test logger to not fatal the test
12+
// on Fatal and not error the test on Error or Critical.
913
IgnoreErrors bool
1014
}
1115

16+
// Test creates a Logger that writes logs to tb.
1217
func Test(tb testing.TB, opts *TestOptions) Logger {
1318
if opts == nil {
1419
opts = &TestOptions{}

0 commit comments

Comments
 (0)