Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Test on Go 1.10 and 1.9 #577

Merged
merged 4 commits into from
Apr 13, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
language: go
sudo: false
go:
- 1.8
- 1.9
- "1.9"
- "1.10"
go_import_path: go.uber.org/zap
env:
global:
Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ PKG_FILES ?= *.go zapcore benchmarks buffer zapgrpc zaptest zaptest/observer int
# stable release.
GO_VERSION := $(shell go version | cut -d " " -f 3)
GO_MINOR_VERSION := $(word 2,$(subst ., ,$(GO_VERSION)))
LINTABLE_MINOR_VERSIONS := 9
LINTABLE_MINOR_VERSIONS := 10
ifneq ($(filter $(LINTABLE_MINOR_VERSIONS),$(GO_MINOR_VERSION)),)
SHOULD_LINT := true
endif
Expand Down
46 changes: 23 additions & 23 deletions array.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,113 +29,113 @@ import (
// Array constructs a field with the given key and ArrayMarshaler. It provides
// a flexible, but still type-safe and efficient, way to add array-like types
// to the logging context. The struct's MarshalLogArray method is called lazily.
func Array(key string, val zapcore.ArrayMarshaler) zapcore.Field {
return zapcore.Field{Key: key, Type: zapcore.ArrayMarshalerType, Interface: val}
func Array(key string, val zapcore.ArrayMarshaler) Field {
return Field{Key: key, Type: zapcore.ArrayMarshalerType, Interface: val}
}

// Bools constructs a field that carries a slice of bools.
func Bools(key string, bs []bool) zapcore.Field {
func Bools(key string, bs []bool) Field {
return Array(key, bools(bs))
}

// ByteStrings constructs a field that carries a slice of []byte, each of which
// must be UTF-8 encoded text.
func ByteStrings(key string, bss [][]byte) zapcore.Field {
func ByteStrings(key string, bss [][]byte) Field {
return Array(key, byteStringsArray(bss))
}

// Complex128s constructs a field that carries a slice of complex numbers.
func Complex128s(key string, nums []complex128) zapcore.Field {
func Complex128s(key string, nums []complex128) Field {
return Array(key, complex128s(nums))
}

// Complex64s constructs a field that carries a slice of complex numbers.
func Complex64s(key string, nums []complex64) zapcore.Field {
func Complex64s(key string, nums []complex64) Field {
return Array(key, complex64s(nums))
}

// Durations constructs a field that carries a slice of time.Durations.
func Durations(key string, ds []time.Duration) zapcore.Field {
func Durations(key string, ds []time.Duration) Field {
return Array(key, durations(ds))
}

// Float64s constructs a field that carries a slice of floats.
func Float64s(key string, nums []float64) zapcore.Field {
func Float64s(key string, nums []float64) Field {
return Array(key, float64s(nums))
}

// Float32s constructs a field that carries a slice of floats.
func Float32s(key string, nums []float32) zapcore.Field {
func Float32s(key string, nums []float32) Field {
return Array(key, float32s(nums))
}

// Ints constructs a field that carries a slice of integers.
func Ints(key string, nums []int) zapcore.Field {
func Ints(key string, nums []int) Field {
return Array(key, ints(nums))
}

// Int64s constructs a field that carries a slice of integers.
func Int64s(key string, nums []int64) zapcore.Field {
func Int64s(key string, nums []int64) Field {
return Array(key, int64s(nums))
}

// Int32s constructs a field that carries a slice of integers.
func Int32s(key string, nums []int32) zapcore.Field {
func Int32s(key string, nums []int32) Field {
return Array(key, int32s(nums))
}

// Int16s constructs a field that carries a slice of integers.
func Int16s(key string, nums []int16) zapcore.Field {
func Int16s(key string, nums []int16) Field {
return Array(key, int16s(nums))
}

// Int8s constructs a field that carries a slice of integers.
func Int8s(key string, nums []int8) zapcore.Field {
func Int8s(key string, nums []int8) Field {
return Array(key, int8s(nums))
}

// Strings constructs a field that carries a slice of strings.
func Strings(key string, ss []string) zapcore.Field {
func Strings(key string, ss []string) Field {
return Array(key, stringArray(ss))
}

// Times constructs a field that carries a slice of time.Times.
func Times(key string, ts []time.Time) zapcore.Field {
func Times(key string, ts []time.Time) Field {
return Array(key, times(ts))
}

// Uints constructs a field that carries a slice of unsigned integers.
func Uints(key string, nums []uint) zapcore.Field {
func Uints(key string, nums []uint) Field {
return Array(key, uints(nums))
}

// Uint64s constructs a field that carries a slice of unsigned integers.
func Uint64s(key string, nums []uint64) zapcore.Field {
func Uint64s(key string, nums []uint64) Field {
return Array(key, uint64s(nums))
}

// Uint32s constructs a field that carries a slice of unsigned integers.
func Uint32s(key string, nums []uint32) zapcore.Field {
func Uint32s(key string, nums []uint32) Field {
return Array(key, uint32s(nums))
}

// Uint16s constructs a field that carries a slice of unsigned integers.
func Uint16s(key string, nums []uint16) zapcore.Field {
func Uint16s(key string, nums []uint16) Field {
return Array(key, uint16s(nums))
}

// Uint8s constructs a field that carries a slice of unsigned integers.
func Uint8s(key string, nums []uint8) zapcore.Field {
func Uint8s(key string, nums []uint8) Field {
return Array(key, uint8s(nums))
}

// Uintptrs constructs a field that carries a slice of pointer addresses.
func Uintptrs(key string, us []uintptr) zapcore.Field {
func Uintptrs(key string, us []uintptr) Field {
return Array(key, uintptrs(us))
}

// Errors constructs a field that carries a slice of errors.
func Errors(key string, errs []error) zapcore.Field {
func Errors(key string, errs []error) Field {
return Array(key, errArray(errs))
}

Expand Down
2 changes: 1 addition & 1 deletion array_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ func BenchmarkBoolsReflect(b *testing.B) {
func TestArrayWrappers(t *testing.T) {
tests := []struct {
desc string
field zapcore.Field
field Field
expected []interface{}
}{
{"empty bools", Bools("", []bool{}), []interface{}(nil)},
Expand Down
4 changes: 2 additions & 2 deletions benchmarks/zap_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -124,8 +124,8 @@ func newSampledLogger(lvl zapcore.Level) *zap.Logger {
))
}

func fakeFields() []zapcore.Field {
return []zapcore.Field{
func fakeFields() []zap.Field {
return []zap.Field{
zap.Int("int", _tenInts[0]),
zap.Ints("ints", _tenInts),
zap.String("string", _tenStrings[0]),
Expand Down
2 changes: 1 addition & 1 deletion config.go
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@ func (cfg Config) buildOptions(errSink zapcore.WriteSyncer) []Option {
}

if len(cfg.InitialFields) > 0 {
fs := make([]zapcore.Field, 0, len(cfg.InitialFields))
fs := make([]Field, 0, len(cfg.InitialFields))
keys := make([]string, 0, len(cfg.InitialFields))
for k := range cfg.InitialFields {
keys = append(keys, k)
Expand Down
6 changes: 3 additions & 3 deletions error.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ var _errArrayElemPool = sync.Pool{New: func() interface{} {
}}

// Error is shorthand for the common idiom NamedError("error", err).
func Error(err error) zapcore.Field {
func Error(err error) Field {
return NamedError("error", err)
}

Expand All @@ -42,11 +42,11 @@ func Error(err error) zapcore.Field {
//
// For the common case in which the key is simply "error", the Error function
// is shorter and less repetitive.
func NamedError(key string, err error) zapcore.Field {
func NamedError(key string, err error) Field {
if err == nil {
return Skip()
}
return zapcore.Field{Key: key, Type: zapcore.ErrorType, Interface: err}
return Field{Key: key, Type: zapcore.ErrorType, Interface: err}
}

type errArray []error
Expand Down
10 changes: 5 additions & 5 deletions error_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,13 +36,13 @@ func TestErrorConstructors(t *testing.T) {

tests := []struct {
name string
field zapcore.Field
expect zapcore.Field
field Field
expect Field
}{
{"Error", Skip(), Error(nil)},
{"Error", zapcore.Field{Key: "error", Type: zapcore.ErrorType, Interface: fail}, Error(fail)},
{"Error", Field{Key: "error", Type: zapcore.ErrorType, Interface: fail}, Error(fail)},
{"NamedError", Skip(), NamedError("foo", nil)},
{"NamedError", zapcore.Field{Key: "foo", Type: zapcore.ErrorType, Interface: fail}, NamedError("foo", fail)},
{"NamedError", Field{Key: "foo", Type: zapcore.ErrorType, Interface: fail}, NamedError("foo", fail)},
{"Any:Error", Any("k", errors.New("v")), NamedError("k", errors.New("v"))},
{"Any:Errors", Any("k", []error{errors.New("v")}), Errors("k", []error{errors.New("v")})},
}
Expand All @@ -58,7 +58,7 @@ func TestErrorConstructors(t *testing.T) {
func TestErrorArrayConstructor(t *testing.T) {
tests := []struct {
desc string
field zapcore.Field
field Field
expected []interface{}
}{
{"empty errors", Errors("", []error{}), []interface{}(nil)},
Expand Down
Loading