diff --git a/Makefile b/Makefile index 1867f28..be2793d 100644 --- a/Makefile +++ b/Makefile @@ -22,13 +22,11 @@ generate: root build .root/src/$(PKG)/tests/data.go \ .root/src/$(PKG)/tests/omitempty.go \ .root/src/$(PKG)/tests/nothing.go \ - .root/src/$(PKG)/tests/camel_case_functions.go .root/bin/easyjson -all .root/src/$(PKG)/tests/data.go .root/bin/easyjson -all .root/src/$(PKG)/tests/nothing.go .root/bin/easyjson -snake_case .root/src/$(PKG)/tests/snake.go .root/bin/easyjson -omit_empty .root/src/$(PKG)/tests/omitempty.go - .root/bin/easyjson -camel_case_functions .root/src/$(PKG)/tests/camel_case_functions.go .root/bin/easyjson -build_tags=use_easyjson .root/src/$(PKG)/benchmark/data.go test: generate root diff --git a/README.md b/README.md index 913777b..e990111 100644 --- a/README.md +++ b/README.md @@ -31,8 +31,6 @@ Usage of .root/bin/easyjson: use snake_case names instead of CamelCase by default -stubs only generate stubs for marshallers/unmarshallers methods - -camel_case_functions - generate functions with CamelCase names instead of under_score by default ``` Using `-all` will generate (un-)marshallers for all structs in the file. By default, structs need to have a line beginning with `easyjson:json` in their docstring, e.g.: diff --git a/bootstrap/bootstrap.go b/bootstrap/bootstrap.go index 39b706f..f9cf3b6 100644 --- a/bootstrap/bootstrap.go +++ b/bootstrap/bootstrap.go @@ -21,10 +21,9 @@ type Generator struct { PkgPath, PkgName string Types []string - NoStdMarshalers bool - SnakeCaseFields bool - CamelCaseFunctions bool - OmitEmpty bool + NoStdMarshalers bool + SnakeCaseFields bool + OmitEmpty bool OutName string BuildTags string @@ -109,9 +108,6 @@ func (g *Generator) writeMain() (path string, err error) { if g.SnakeCaseFields { fmt.Fprintln(f, " g.UseSnakeCaseFieldNamer()") } - if g.CamelCaseFunctions { - fmt.Fprintln(f, " g.UseCamelCaseFunctionNamer()") - } if g.OmitEmpty { fmt.Fprintln(f, " g.OmitEmpty()") } diff --git a/easyjson/main.go b/easyjson/main.go index 7fe83a6..abcd183 100644 --- a/easyjson/main.go +++ b/easyjson/main.go @@ -16,7 +16,6 @@ import ( var buildTags = flag.String("build_tags", "", "build tags to add to generated file") var snakeCaseFields = flag.Bool("snake_case", false, "use snake_case names instead of CamelCase by default") -var camelCaseFunctions = flag.Bool("camel_case_functions", false, "generate functions with CamelCase names instead of under_score by default") var noStdMarshalers = flag.Bool("no_std_marshalers", false, "don't generate MarshalJSON/UnmarshalJSON methods") var omitEmpty = flag.Bool("omit_empty", false, "omit empty fields by default") var allStructs = flag.Bool("all", false, "generate un-/marshallers for all structs in a file") @@ -43,18 +42,17 @@ func generate(fname string) (err error) { } g := bootstrap.Generator{ - BuildTags: *buildTags, - PkgPath: p.PkgPath, - PkgName: p.PkgName, - Types: p.StructNames, - SnakeCaseFields: *snakeCaseFields, - CamelCaseFunctions: *camelCaseFunctions, - NoStdMarshalers: *noStdMarshalers, - OmitEmpty: *omitEmpty, - LeaveTemps: *leaveTemps, - OutName: outName, - StubsOnly: *stubs, - NoFormat: *noformat, + BuildTags: *buildTags, + PkgPath: p.PkgPath, + PkgName: p.PkgName, + Types: p.StructNames, + SnakeCaseFields: *snakeCaseFields, + NoStdMarshalers: *noStdMarshalers, + OmitEmpty: *omitEmpty, + LeaveTemps: *leaveTemps, + OutName: outName, + StubsOnly: *stubs, + NoFormat: *noformat, } if err := g.Run(); err != nil { diff --git a/gen/generator.go b/gen/generator.go index fe7d4e2..9ebe4f5 100644 --- a/gen/generator.go +++ b/gen/generator.go @@ -67,8 +67,7 @@ func NewGenerator(filename string) *Generator { "encoding/json": "json", }, fieldNamer: DefaultFieldNamer{}, - functionNamer: UnderScoreFunctionNamer{}, - //functionNamer: CamelCaseFunctionNamer{}, + functionNamer: CamelCaseFunctionNamer{}, marshallers: make(map[reflect.Type]bool), typesSeen: make(map[reflect.Type]bool), functionNames: make(map[string]reflect.Type), @@ -104,16 +103,6 @@ func (g *Generator) UseSnakeCaseFieldNamer() { g.fieldNamer = SnakeCaseFieldNamer{} } -// SetFunctionNamer sets function naming strategy. -func (g *Generator) SetFunctionNamer(n FunctionNamer) { - g.functionNamer = n -} - -// UseCamelCaseFunctionNamer sets CamelCase function naming strategy. -func (g *Generator) UseCamelCaseFunctionNamer() { - g.functionNamer = CamelCaseFunctionNamer{} -} - // NoStdMarshalers instructs not to generate standard MarshalJSON/UnmarshalJSON // methods (only the custom interface). func (g *Generator) NoStdMarshalers() { @@ -414,10 +403,3 @@ func (CamelCaseFunctionNamer) GetName(keepFirst bool, parts ...string) string { } return buf.String() } - -// UnderScoreFunctionNamer implements FunctionNamer interface with under_score format -type UnderScoreFunctionNamer struct{} - -func (UnderScoreFunctionNamer) GetName(keepFirst bool, parts ...string) string { - return strings.Join(parts, "_") -} diff --git a/gen/generator_test.go b/gen/generator_test.go index 64e164d..ee77d17 100644 --- a/gen/generator_test.go +++ b/gen/generator_test.go @@ -55,13 +55,3 @@ func TestCamelCaseFunctionNamer(t *testing.T) { } } } - -func TestUnderScoreFunctionNamer(t *testing.T) { - namer := UnderScoreFunctionNamer{} - for i, test := range getFunctionNamerCases() { - got := namer.GetName(test.keepFirst, test.parts...) - if got != test.underScoreOut { - t.Errorf("[%d] UnderScoreFunctionNamer.GetName(%v) = %s; want %s", i, test.parts, got, test.underScoreOut) - } - } -} diff --git a/tests/basic_test.go b/tests/basic_test.go index 0450c67..d2eac28 100644 --- a/tests/basic_test.go +++ b/tests/basic_test.go @@ -33,7 +33,6 @@ var testCases = []struct { {&mapsValue, mapsString}, {&deepNestValue, deepNestString}, {&IntsValue, IntsString}, - {&camelCasesFunctionsValue, camelCasesFunctionsString}, } func TestMarshal(t *testing.T) { diff --git a/tests/camel_case_functions.go b/tests/camel_case_functions.go deleted file mode 100644 index 94a44e8..0000000 --- a/tests/camel_case_functions.go +++ /dev/null @@ -1,9 +0,0 @@ -package tests - -//easyjson:json -type CamelCasesFunctions struct { - Field string -} - -var camelCasesFunctionsValue = CamelCasesFunctions{Field: "test"} -var camelCasesFunctionsString = `{"Field":"test"}`