Skip to content

Commit

Permalink
fix issue #4
Browse files Browse the repository at this point in the history
  • Loading branch information
ghostiam committed Oct 24, 2023
1 parent af772e8 commit d7b06e7
Show file tree
Hide file tree
Showing 6 changed files with 51 additions and 15 deletions.
8 changes: 6 additions & 2 deletions processor.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,12 @@ func (c *processor) process(n ast.Node) (*Result, error) {
switch x := n.(type) {
case *ast.AssignStmt:
// Skip any assignment to the field.
for _, lhs := range x.Lhs {
c.filter.AddPos(lhs.Pos())
for _, s := range x.Lhs {
c.filter.AddPos(s.Pos())

if se, ok := s.(*ast.StarExpr); ok {
c.filter.AddPos(se.X.Pos())
}
}

case *ast.IncDecStmt:
Expand Down
37 changes: 25 additions & 12 deletions testdata/proto/test.pb.go

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

3 changes: 3 additions & 0 deletions testdata/proto/test.proto
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@ message Test {
string s = 9;
Embedded embedded = 10;
repeated Embedded repeated_embeddeds = 11;

// issue #4
optional bool opt_bool = 12;
}

message Embedded {
Expand Down
2 changes: 1 addition & 1 deletion testdata/proto/test_grpc.pb.go

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

8 changes: 8 additions & 0 deletions testdata/test.go
Original file line number Diff line number Diff line change
Expand Up @@ -147,4 +147,12 @@ func testValid(t *proto.Test) {
ch <- t.GetS()

t.Equal(&proto.Test{S: "test", I64: 42})

// issue #4
*t.Embedded = proto.Embedded{}

v := &proto.Test{
OptBool: new(bool),
}
*v.OptBool = true
}
8 changes: 8 additions & 0 deletions testdata/test.go.golden
Original file line number Diff line number Diff line change
Expand Up @@ -147,4 +147,12 @@ func testValid(t *proto.Test) {
ch <- t.GetS()

t.Equal(&proto.Test{S: "test", I64: 42})

// issue #4
*t.Embedded = proto.Embedded{}

v := &proto.Test{
OptBool: new(bool),
}
*v.OptBool = true
}

0 comments on commit d7b06e7

Please sign in to comment.