Skip to content

Commit

Permalink
Document new format for options usage (and mention paths=source_relat…
Browse files Browse the repository at this point in the history
…ive)
  • Loading branch information
chkohner committed Jan 11, 2021
1 parent 42da43b commit abed81c
Showing 1 changed file with 19 additions and 7 deletions.
26 changes: 19 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -67,19 +67,31 @@ json.Unmarshal(bs, &result)

The generator supports options you can specify via the command-line:

* `enums_as_ints` - Render enums as integers instead of strings.
* `emit_defaults` - Render fields with zero values.
* `orig_name` - Use original (.proto file) name for fields.
* `allow_unknown` - Allow messages to contain unknown fields when unmarshaling
- `enums_as_ints={bool}` - Render enums as integers instead of strings.
- `emit_defaults={bool}` - Render fields with zero values.
- `orig_name={bool}` - Use original (.proto file) name for fields.
- `allow_unknown={bool}` - Allow messages to contain unknown fields when unmarshaling

It also includes the "standard" options available to all [protogen](https://pkg.go.dev/google.golang.org/protobuf/compiler/protogen?tab=doc)-based plugins:

- `import_path={path}` - Override the import path
- `paths=source_relative` - Derive the output path from the input path
- etc.

These can be set as part of the `--go-json_out` value:

```
protoc --go-json_out=emit_defaults:.
```sh
protoc --go-json_opt=emit_defaults=true:.
```

You can specify multiple using a `,`:

```sh
protoc --go-json_out=enums_as_ints=true,emit_defaults=true:.
```
protoc --go-json_out=enums_as_ints,emit_defaults:.

Alternatively, you may also specify options using the `--go-json_opt` value:

```sh
protoc --go-json_out:. --go-json_opt=emit_defaults=true,enums_as_ints=true
```

0 comments on commit abed81c

Please sign in to comment.