-
Notifications
You must be signed in to change notification settings - Fork 192
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
struct fields can be tagged with `msg:",omitempty"` Such fields will not be serialized if they contain their zero values. For structs with many optional fields, the space and time savings can be substantial. Further details: * to avoid allocating memory, we reuse the structs provided to deserialize into, without clearing totally first. Available fields overwrite any prior values. If a field is missing on the wire, we treat it as if the wire held a nil value. This means that maps, slices, and pointers continue as before. Fixes #103
- Loading branch information
Showing
19 changed files
with
998 additions
and
88 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
package cfg | ||
|
||
import ( | ||
"flag" | ||
) | ||
|
||
type MsgpConfig struct { | ||
Out string | ||
GoFile string | ||
Encode bool | ||
Marshal bool | ||
Tests bool | ||
Unexported bool | ||
} | ||
|
||
// call DefineFlags before myflags.Parse() | ||
func (c *MsgpConfig) DefineFlags(fs *flag.FlagSet) { | ||
fs.StringVar(&c.Out, "o", "", "output file") | ||
fs.StringVar(&c.GoFile, "file", "", "input file") | ||
fs.BoolVar(&c.Encode, "io", true, "create Encode and Decode methods") | ||
fs.BoolVar(&c.Marshal, "marshal", true, "create Marshal and Unmarshal methods") | ||
fs.BoolVar(&c.Tests, "tests", true, "create tests and benchmarks") | ||
fs.BoolVar(&c.Unexported, "unexported", false, "also process unexported types") | ||
} | ||
|
||
// call c.ValidateConfig() after myflags.Parse() | ||
func (c *MsgpConfig) ValidateConfig() error { | ||
return nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.