Skip to content

Commit

Permalink
Merge pull request #39 from kei2100/buf
Browse files Browse the repository at this point in the history
feat: buf support
  • Loading branch information
kei2100 committed Feb 16, 2023
2 parents 356ae51 + fc14c60 commit edfeb20
Show file tree
Hide file tree
Showing 2 changed files with 50 additions and 1 deletion.
36 changes: 35 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,8 @@ message SimpleMessage {
}
```

Generate the code
Generate the code by protoc (Alternatively, you can [use buf](#Using-Buf))

```
PROTOC_GEN_MARSHAL_ZAP_VERSION=v0.1.x # replace latest version
protoc -I. -I$(go env GOMODCACHE)/github.com/kei2100/protoc-gen-marshal-zap@${PROTOC_GEN_MARSHAL_ZAP_VERSION} --go_out=. --marshal-zap_out=. simple.proto
Expand Down Expand Up @@ -73,6 +74,39 @@ func (x *SimpleMessage) MarshalLogObject(enc zapcore.ObjectEncoder) error {
}
```

## Using Buf

marshal-zap [Buf](https://buf.build/) repository is here.

https://buf.build/kei2100/protoc-gen-marshal-zap

So, you can `buf generate` by setting up the following in your project.

```yaml
# buf.yaml
version: v1
deps:
- buf.build/kei2100/protoc-gen-marshal-zap
breaking:
use:
- FILE
lint:
use:
- DEFAULT
```
```yaml
# buf.gen.yaml
version: v1
plugins:
- plugin: buf.build/protocolbuffers/go:v1.28.1
out: gen/go
opt: paths=source_relative
- plugin: marshal-zap
out: gen/go
opt: paths=source_relative
```
## Development
Compile marshal-zap.proto
```
Expand Down
15 changes: 15 additions & 0 deletions buf.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
version: v1
name: buf.build/kei2100/protoc-gen-marshal-zap

lint:
use:
- MINIMAL
except:
- PACKAGE_DIRECTORY_MATCH
breaking:
use:
- FILE
build:
excludes:
- example
- test

0 comments on commit edfeb20

Please sign in to comment.