diff --git a/opt/gotemplate_Bool.go b/opt/gotemplate_Bool.go index 26f076b..89e6132 100644 --- a/opt/gotemplate_Bool.go +++ b/opt/gotemplate_Bool.go @@ -1,3 +1,5 @@ +// generated by gotemplate + package opt import ( diff --git a/opt/gotemplate_Float32.go b/opt/gotemplate_Float32.go index 82056ba..93ade1c 100644 --- a/opt/gotemplate_Float32.go +++ b/opt/gotemplate_Float32.go @@ -1,3 +1,5 @@ +// generated by gotemplate + package opt import ( diff --git a/opt/gotemplate_Float64.go b/opt/gotemplate_Float64.go index 269a254..90af91b 100644 --- a/opt/gotemplate_Float64.go +++ b/opt/gotemplate_Float64.go @@ -1,3 +1,5 @@ +// generated by gotemplate + package opt import ( diff --git a/opt/gotemplate_Int.go b/opt/gotemplate_Int.go index 62c75ed..71e74e8 100644 --- a/opt/gotemplate_Int.go +++ b/opt/gotemplate_Int.go @@ -1,3 +1,5 @@ +// generated by gotemplate + package opt import ( diff --git a/opt/gotemplate_Int16.go b/opt/gotemplate_Int16.go index 44a96f3..987e3df 100644 --- a/opt/gotemplate_Int16.go +++ b/opt/gotemplate_Int16.go @@ -1,3 +1,5 @@ +// generated by gotemplate + package opt import ( diff --git a/opt/gotemplate_Int32.go b/opt/gotemplate_Int32.go index 305fedb..e5f30d8 100644 --- a/opt/gotemplate_Int32.go +++ b/opt/gotemplate_Int32.go @@ -1,3 +1,5 @@ +// generated by gotemplate + package opt import ( diff --git a/opt/gotemplate_Int64.go b/opt/gotemplate_Int64.go index c3402ad..ff67a33 100644 --- a/opt/gotemplate_Int64.go +++ b/opt/gotemplate_Int64.go @@ -1,3 +1,5 @@ +// generated by gotemplate + package opt import ( diff --git a/opt/gotemplate_Int8.go b/opt/gotemplate_Int8.go index 3c8a6e4..41312d1 100644 --- a/opt/gotemplate_Int8.go +++ b/opt/gotemplate_Int8.go @@ -1,3 +1,5 @@ +// generated by gotemplate + package opt import ( diff --git a/opt/gotemplate_String.go b/opt/gotemplate_String.go index b9bba45..3d818fa 100644 --- a/opt/gotemplate_String.go +++ b/opt/gotemplate_String.go @@ -1,3 +1,5 @@ +// generated by gotemplate + package opt import ( diff --git a/opt/gotemplate_Uint.go b/opt/gotemplate_Uint.go index af71b9b..367db67 100644 --- a/opt/gotemplate_Uint.go +++ b/opt/gotemplate_Uint.go @@ -1,3 +1,5 @@ +// generated by gotemplate + package opt import ( diff --git a/opt/gotemplate_Uint16.go b/opt/gotemplate_Uint16.go index e47f62b..6abc71d 100644 --- a/opt/gotemplate_Uint16.go +++ b/opt/gotemplate_Uint16.go @@ -1,3 +1,5 @@ +// generated by gotemplate + package opt import ( diff --git a/opt/gotemplate_Uint32.go b/opt/gotemplate_Uint32.go index 286c99a..490945c 100644 --- a/opt/gotemplate_Uint32.go +++ b/opt/gotemplate_Uint32.go @@ -1,3 +1,5 @@ +// generated by gotemplate + package opt import ( diff --git a/opt/gotemplate_Uint64.go b/opt/gotemplate_Uint64.go index 2ec9237..37d2d41 100644 --- a/opt/gotemplate_Uint64.go +++ b/opt/gotemplate_Uint64.go @@ -1,3 +1,5 @@ +// generated by gotemplate + package opt import ( diff --git a/opt/gotemplate_Uint8.go b/opt/gotemplate_Uint8.go index 8306a97..55c4cdb 100644 --- a/opt/gotemplate_Uint8.go +++ b/opt/gotemplate_Uint8.go @@ -1,3 +1,5 @@ +// generated by gotemplate + package opt import ( diff --git a/opt/optional/opt.go b/opt/optional/opt.go index d828b97..6d3a079 100644 --- a/opt/optional/opt.go +++ b/opt/optional/opt.go @@ -1,3 +1,5 @@ +// +build none + package optional import ( diff --git a/opt/opts.go b/opt/opts.go index 7f81f6f..3617f7f 100644 --- a/opt/opts.go +++ b/opt/opts.go @@ -1,5 +1,6 @@ package opt +//go:generate sed -i "s/\\+build none/generated by gotemplate/" optional/opt.go //go:generate gotemplate "github.com/mailru/easyjson/opt/optional" Int(int) //go:generate gotemplate "github.com/mailru/easyjson/opt/optional" Uint(uint) @@ -18,3 +19,4 @@ package opt //go:generate gotemplate "github.com/mailru/easyjson/opt/optional" Bool(bool) //go:generate gotemplate "github.com/mailru/easyjson/opt/optional" String(string) +//go:generate sed -i "s/generated by gotemplate/+build none/" optional/opt.go diff --git a/tests/basic_test.go b/tests/basic_test.go index 5115668..9c97614 100644 --- a/tests/basic_test.go +++ b/tests/basic_test.go @@ -3,8 +3,28 @@ package tests import ( "reflect" "testing" + + "encoding/json" ) +type testType interface { + json.Marshaler + json.Unmarshaler +} + +var testCases = []struct { + Decoded testType + Encoded string +}{ + {&primitiveTypesValue, primitiveTypesString}, + {&structsValue, structsString}, + {&omitEmptyValue, omitEmptyString}, + {&snakeStructValue, snakeStructString}, + {&omitEmptyDefaultValue, omitEmptyDefaultString}, + {&optsValue, optsString}, + {&rawValue, rawString}, +} + func TestMarshal(t *testing.T) { for i, test := range testCases { data, err := test.Decoded.MarshalJSON() diff --git a/tests/data.go b/tests/data.go index bc57e00..806e4e3 100644 --- a/tests/data.go +++ b/tests/data.go @@ -1,7 +1,6 @@ package tests import ( - "encoding/json" "fmt" "math" @@ -9,24 +8,6 @@ import ( "github.com/mailru/easyjson/opt" ) -type testType interface { - json.Marshaler - json.Unmarshaler -} - -var testCases = []struct { - Decoded testType - Encoded string -}{ - {&primitiveTypesValue, primitiveTypesString}, - {&structsValue, structsString}, - {&omitEmptyValue, omitEmptyString}, - {&snakeStructValue, snakeStructString}, - {&omitEmptyDefaultValue, omitEmptyDefaultString}, - {&optsValue, optsString}, - {&rawValue, rawString}, -} - type PrimitiveTypes struct { String string Bool bool