-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #7 from snprajwal/fix-proto2
fix: handle dereference in proto2 bindings
- Loading branch information
Showing
8 changed files
with
285 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
.PHONY: test | ||
test: | ||
cd testdata && make vendor | ||
$(MAKE) -C testdata vendor | ||
go test -v ./... | ||
|
||
.PHONY: install | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
syntax = "proto2"; | ||
|
||
option go_package = "github.com/ghostiam/protogetter/testdata/proto"; | ||
|
||
message TestProto2 { | ||
required double d = 1; | ||
required float f = 2; | ||
required int32 i32 = 3; | ||
required int64 i64 = 4; | ||
optional uint32 u32 = 5; | ||
optional uint64 u64 = 6; | ||
optional bool t = 7; | ||
optional bytes b = 8; | ||
optional string s = 9; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
package testdata | ||
|
||
import ( | ||
"github.com/ghostiam/protogetter/testdata/proto" | ||
) | ||
|
||
func testInvalidProto2(t *proto.TestProto2) { | ||
_ = *t.D // want `avoid direct access to proto field \*t\.D, use t\.GetD\(\) instead` | ||
_ = *t.F // want `avoid direct access to proto field \*t\.F, use t\.GetF\(\) instead` | ||
_ = *t.I32 // want `avoid direct access to proto field \*t\.I32, use t\.GetI32\(\) instead` | ||
_ = *t.I64 // want `avoid direct access to proto field \*t\.I64, use t\.GetI64\(\) instead` | ||
_ = *t.U32 // want `avoid direct access to proto field \*t\.U32, use t\.GetU32\(\) instead` | ||
_ = *t.U64 // want `avoid direct access to proto field \*t\.U64, use t\.GetU64\(\) instead` | ||
_ = *t.T // want `avoid direct access to proto field \*t\.T, use t\.GetT\(\) instead` | ||
_ = t.B // want `avoid direct access to proto field t\.B, use t\.GetB\(\) instead` | ||
_ = *t.S // want `avoid direct access to proto field \*t\.S, use t\.GetS\(\) instead` | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
package testdata | ||
|
||
import ( | ||
"github.com/ghostiam/protogetter/testdata/proto" | ||
) | ||
|
||
func testInvalidProto2(t *proto.TestProto2) { | ||
_ = t.GetD() // want `avoid direct access to proto field \*t\.D, use t\.GetD\(\) instead` | ||
_ = t.GetF() // want `avoid direct access to proto field \*t\.F, use t\.GetF\(\) instead` | ||
_ = t.GetI32() // want `avoid direct access to proto field \*t\.I32, use t\.GetI32\(\) instead` | ||
_ = t.GetI64() // want `avoid direct access to proto field \*t\.I64, use t\.GetI64\(\) instead` | ||
_ = t.GetU32() // want `avoid direct access to proto field \*t\.U32, use t\.GetU32\(\) instead` | ||
_ = t.GetU64() // want `avoid direct access to proto field \*t\.U64, use t\.GetU64\(\) instead` | ||
_ = t.GetT() // want `avoid direct access to proto field \*t\.T, use t\.GetT\(\) instead` | ||
_ = t.GetB() // want `avoid direct access to proto field t\.B, use t\.GetB\(\) instead` | ||
_ = t.GetS() // want `avoid direct access to proto field \*t\.S, use t\.GetS\(\) instead` | ||
} |