1
1
# 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)
3
3
4
4
5
5
## Get started
6
6
7
7
``` sh
8
- go install github.com/francoispqt/gojay/gojaygen
8
+ go install github.com/francoispqt/gojay/gojay
9
9
```
10
10
11
- ## Generate code
11
+ ## Generate code
12
12
13
13
### Basic command
14
14
The basic command is straightforward and easy to use:
15
15
``` sh
16
16
cd $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
18
18
```
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.
20
20
21
21
### Using flags
22
22
- 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.
25
25
- o Output file (relative or absolute path)
26
26
- p Pool to reuse object (using sync.Pool)
27
27
28
- Examples:
28
+ Examples:
29
29
30
30
- Generate ` SomeType ` type in ` /tmp/myproj ` go package, write to file ` output.go ` :
31
31
``` sh
@@ -46,16 +46,16 @@ You can add tags to your structs to control:
46
46
- the use of omitempty methods for marshaling
47
47
- timeFormat (java style data format)
48
48
- timeLayout (golang time layout)
49
-
50
49
51
- ### Example:
50
+
51
+ ### Example:
52
52
``` go
53
53
type 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"`
59
59
}
60
60
```
61
61
0 commit comments