Skip to content

Commit

Permalink
Rewrite using protogen
Browse files Browse the repository at this point in the history
  • Loading branch information
wdullaer committed Jul 18, 2022
1 parent e2172f1 commit bb83468
Show file tree
Hide file tree
Showing 15 changed files with 574 additions and 734 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ jobs:
- uses: actions/checkout@v2
- uses: actions/setup-go@v2
with:
go-version: '1.16'
go-version: '1.18'
- uses: arduino/setup-protoc@master
with:
version: '3.13.0'
Expand Down
13 changes: 4 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,12 @@ protoc-gen-marshal-zap is a protoc plugin to generate code that implements zapco
- protoc compiler
- protoc-gen-go

See https://github.com/golang/protobuf#installation
See https://github.com/protocolbuffers/protobuf-go

## Installation

```
GO111MODULE=off go get -u github.com/kei2100/protoc-gen-marshal-zap/plugin/protoc-gen-marshal-zap
go install github.com/kei2100/protoc-gen-marshal-zap/plugin/protoc-gen-marshal-zap
```

## Usage
Expand Down Expand Up @@ -47,23 +47,18 @@ simple.pb.marshal-zap.go # auto-generated by protoc-gen-marshal-zap
simple.proto # original proto file
```

`simple.pb.marshal-zap.go` is generated as follows
`simple_marshal_zap.pb.go` is generated as follows

```go
// Code generated by protoc-gen-marshal-zap. DO NOT EDIT.
// source: simple.pb.go
// source: simple.proto

package simple

import (
"go.uber.org/zap/zapcore"
"strconv"
)

// Reference imports to suppress errors if they are not otherwise used.
var _ = zapcore.NewNopCore
var _ = strconv.FormatInt

func (x *SimpleMessage) MarshalLogObject(enc zapcore.ObjectEncoder) error {
if x == nil {
return nil
Expand Down
15 changes: 7 additions & 8 deletions example/simple/simple.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

25 changes: 0 additions & 25 deletions example/simple/simple.pb.marshal-zap.go

This file was deleted.

2 changes: 2 additions & 0 deletions example/simple/simple.proto
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ package simple;
// If you want to use "marshal_zap.mask" option, import "marshal-zap.proto"
import "marshal-zap.proto";

option go_package = "github.com/kei2100/protoc-gen-marshal-zap/example/simple";

message SimpleMessage {
string message = 1;
string secret_message = 2 [(marshal_zap.mask) = true];
Expand Down
21 changes: 21 additions & 0 deletions example/simple/simple_marshall_zap.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

19 changes: 12 additions & 7 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,12 +1,17 @@
module github.com/kei2100/protoc-gen-marshal-zap

go 1.13
go 1.18

require (
github.com/golang/protobuf v1.4.2
github.com/lyft/protoc-gen-star v0.5.1
github.com/spf13/afero v1.3.4 // indirect
github.com/stretchr/testify v1.6.1
go.uber.org/zap v1.14.1
google.golang.org/protobuf v1.25.0
github.com/stretchr/testify v1.8.0
go.uber.org/zap v1.21.0
google.golang.org/protobuf v1.28.0
)

require (
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
go.uber.org/atomic v1.9.0 // indirect
go.uber.org/multierr v1.8.0 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
)
Loading

0 comments on commit bb83468

Please sign in to comment.