mirror of
https://github.com/netbirdio/easyjson.git
synced 2026-05-22 18:44:42 -07:00
Merge remote-tracking branch 'remotes/origin/master' into camel_case_functions
Conflicts: Makefile
This commit is contained in:
@@ -21,9 +21,11 @@ generate: root build
|
||||
.root/src/$(PKG)/tests/snake.go \
|
||||
.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
|
||||
|
||||
+14
-9
@@ -51,20 +51,23 @@ func (g *Generator) writeStub() error {
|
||||
fmt.Fprintln(f, "// compilable during generation.")
|
||||
fmt.Fprintln(f)
|
||||
fmt.Fprintln(f, "package ", g.PkgName)
|
||||
fmt.Fprintln(f)
|
||||
fmt.Fprintln(f, "import (")
|
||||
fmt.Fprintln(f, ` "`+pkgWriter+`"`)
|
||||
fmt.Fprintln(f, ` "`+pkgLexer+`"`)
|
||||
fmt.Fprintln(f, ")")
|
||||
|
||||
if len(g.Types) > 0 {
|
||||
fmt.Fprintln(f)
|
||||
fmt.Fprintln(f, "import (")
|
||||
fmt.Fprintln(f, ` "`+pkgWriter+`"`)
|
||||
fmt.Fprintln(f, ` "`+pkgLexer+`"`)
|
||||
fmt.Fprintln(f, ")")
|
||||
}
|
||||
|
||||
for _, t := range g.Types {
|
||||
fmt.Fprintln(f)
|
||||
if !g.NoStdMarshalers {
|
||||
fmt.Fprintln(f, "func (*", t, ") MarshalJSON() ([]byte, error) { return nil, nil }")
|
||||
fmt.Fprintln(f, "func (", t, ") MarshalJSON() ([]byte, error) { return nil, nil }")
|
||||
fmt.Fprintln(f, "func (*", t, ") UnmarshalJSON([]byte) error { return nil }")
|
||||
}
|
||||
|
||||
fmt.Fprintln(f, "func (*", t, ") MarshalEasyJSON(w *jwriter.Writer) {}")
|
||||
fmt.Fprintln(f, "func (", t, ") MarshalEasyJSON(w *jwriter.Writer) {}")
|
||||
fmt.Fprintln(f, "func (*", t, ") UnmarshalEasyJSON(l *jlexer.Lexer) {}")
|
||||
fmt.Fprintln(f)
|
||||
fmt.Fprintln(f, "type EasyJSON_exporter_"+t+" *"+t)
|
||||
@@ -91,8 +94,10 @@ func (g *Generator) writeMain() (path string, err error) {
|
||||
fmt.Fprintln(f, ` "os"`)
|
||||
fmt.Fprintln(f)
|
||||
fmt.Fprintf(f, " %q\n", genPackage)
|
||||
fmt.Fprintln(f)
|
||||
fmt.Fprintf(f, " pkg %q\n", g.PkgPath)
|
||||
if len(g.Types) > 0 {
|
||||
fmt.Fprintln(f)
|
||||
fmt.Fprintf(f, " pkg %q\n", g.PkgPath)
|
||||
}
|
||||
fmt.Fprintln(f, ")")
|
||||
fmt.Fprintln(f)
|
||||
fmt.Fprintln(f, "func main() {")
|
||||
|
||||
+6
-1
@@ -174,7 +174,12 @@ func (g *Generator) printHeader() {
|
||||
|
||||
fmt.Println(")")
|
||||
fmt.Println("")
|
||||
fmt.Println("var _ = json.RawMessage{} // suppress unused package warning")
|
||||
fmt.Println("// suppress unused package warning")
|
||||
fmt.Println("var (")
|
||||
fmt.Println(" _ = json.RawMessage{}")
|
||||
fmt.Println(" _ = jlexer.Lexer{}")
|
||||
fmt.Println(" _ = jwriter.Writer{}")
|
||||
fmt.Println(")")
|
||||
|
||||
fmt.Println()
|
||||
}
|
||||
|
||||
+8
-3
@@ -437,8 +437,9 @@ var mapsString = `{` +
|
||||
`}`
|
||||
|
||||
type DeepNest struct {
|
||||
SliceMap map[Str][]Str
|
||||
MapSlice []map[Str]Str
|
||||
SliceMap map[Str][]Str
|
||||
SliceMap1 map[Str][]Str
|
||||
MapSlice []map[Str]Str
|
||||
}
|
||||
|
||||
var deepNestValue = DeepNest{
|
||||
@@ -447,6 +448,8 @@ var deepNestValue = DeepNest{
|
||||
"0",
|
||||
"1",
|
||||
},
|
||||
},
|
||||
SliceMap1: map[Str][]Str{
|
||||
"testSliceMap2": nil,
|
||||
},
|
||||
MapSlice: []map[Str]Str{
|
||||
@@ -458,7 +461,9 @@ var deepNestValue = DeepNest{
|
||||
|
||||
var deepNestString = `{` +
|
||||
`"SliceMap":{` +
|
||||
`"testSliceMap1":["0","1"],` +
|
||||
`"testSliceMap1":["0","1"]` +
|
||||
`},` +
|
||||
`"SliceMap1":{` +
|
||||
`"testSliceMap2":[]` +
|
||||
`},` +
|
||||
`"MapSlice":[` +
|
||||
|
||||
@@ -0,0 +1,3 @@
|
||||
package tests
|
||||
|
||||
// No structs in this file
|
||||
Reference in New Issue
Block a user