11# Gojay code generator
2- This package provides a command line tool to generate gojay's marshaling and unmarshing interface implementation for custom struct type(s)
2+ This package provides a command line tool to generate gojay's marshaling and unmarshaling interface implementation for custom struct type(s)
33
44
55## Get started
66
77``` sh
8- go install github.com/francoispqt/gojay/gojaygen
8+ go install github.com/francoispqt/gojay/gojay
99```
1010
11- ## Generate code
11+ ## Generate code
1212
1313### Basic command
1414The basic command is straightforward and easy to use:
1515``` sh
1616cd $GOPATH /src/github.com/user/project
17- gojaygen -s . -p true -t MyType -o output.go
17+ gojay -s . -p true -t MyType -o output.go
1818```
19- If you just want to the output to stdout, omit the -o flag.
19+ If you just want to the output to stdout, omit the -o flag.
2020
2121### Using flags
2222- s Source file/dir path, can be a relative or absolute path
@@ -25,7 +25,7 @@ If you just want to the output to stdout, omit the -o flag.
2525- o Output file (relative or absolute path)
2626- p Pool to reuse object (using sync.Pool)
2727
28- Examples:
28+ Examples:
2929
3030- Generate ` SomeType ` type in ` /tmp/myproj ` go package, write to file ` output.go ` :
3131``` sh
@@ -46,16 +46,16 @@ You can add tags to your structs to control:
4646- the use of omitempty methods for marshaling
4747- timeFormat (java style data format)
4848- timeLayout (golang time layout)
49-
5049
51- ### Example:
50+
51+ ### Example:
5252``` go
5353type A struct {
54- Str string ` json:"string"`
55- StrOmitEmpty string ` json:"stringOrEmpty,omitempty"`
56- Skip string ` json:"-"`
57- StartTime time.Time ` json:"startDate" timeFormat:"yyyy-MM-dd HH:mm:ss"`
58- EndTime *time.Time ` json:"endDate" timeLayout:"2006-01-02 15:04:05"`
54+ Str string ` json:"string"`
55+ StrOmitEmpty string ` json:"stringOrEmpty,omitempty"`
56+ Skip string ` json:"-"`
57+ StartTime time.Time ` json:"startDate" timeFormat:"yyyy-MM-dd HH:mm:ss"`
58+ EndTime *time.Time ` json:"endDate" timeLayout:"2006-01-02 15:04:05"`
5959}
6060```
6161
0 commit comments