diff --git a/go.mod b/go.mod index 96a349c..52218be 100644 --- a/go.mod +++ b/go.mod @@ -3,7 +3,7 @@ module github.com/nilslice/protolock go 1.21 require ( - github.com/emicklei/proto v1.9.1 + github.com/emicklei/proto v1.13.2 github.com/extism/go-sdk v1.0.0 github.com/stretchr/testify v1.8.4 ) diff --git a/go.sum b/go.sum index 81f4663..6a0a581 100644 --- a/go.sum +++ b/go.sum @@ -2,6 +2,8 @@ github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/emicklei/proto v1.9.1 h1:MUgjFo5xlMwYv72TnF5xmmdKZ04u+dVbv6wdARv16D8= github.com/emicklei/proto v1.9.1/go.mod h1:rn1FgRS/FANiZdD2djyH7TMA9jdRDcYQ9IEN9yvjX0A= +github.com/emicklei/proto v1.13.2 h1:z/etSFO3uyXeuEsVPzfl56WNgzcvIr42aQazXaQmFZY= +github.com/emicklei/proto v1.13.2/go.mod h1:rn1FgRS/FANiZdD2djyH7TMA9jdRDcYQ9IEN9yvjX0A= github.com/extism/go-sdk v1.0.0 h1://UAyiQGok1ihrlzpkfF6UTY5TwJs6hKJBXnQ0sui20= github.com/extism/go-sdk v1.0.0/go.mod h1:xUfKSEQndAvHBc1Ohdre0e+UdnRzUpVfbA8QLcx4fbY= github.com/gobwas/glob v0.2.3 h1:A4xDbljILXROh+kObIiy5kIaPYD8e96x1tgBhUI5J+Y= diff --git a/parse_test.go b/parse_test.go index 507165f..c1a70a5 100644 --- a/parse_test.go +++ b/parse_test.go @@ -212,6 +212,14 @@ message Channel { } ` +const protoWithCStyleInlineComments = ` +syntax = "proto3"; + +message Example { + optional /* i'm a comment */ bool field = 1; +} +` + var gpfPath = filepath.Join("testdata", "getProtoFiles") func TestParseSingleQuoteReservedNames(t *testing.T) { @@ -503,3 +511,24 @@ func TestGetProtoFilesIgnoresMultiple(t *testing.T) { path = filepath.Join(gpfPath, "include", "include.proto") assert.Contains(t, files, path) } + +func TestCStyleInlineComments(t *testing.T) { + r := strings.NewReader(protoWithCStyleInlineComments) + + entry, err := Parse("test:protoWithCStyleInlineComments", r) + assert.NoError(t, err) + assert.Len(t, entry.Messages, 1) + + example := entry.Messages[0] + assert.Len(t, example.Fields, 1) + assert.Equal(t, example.Name, "Example") + + // message Example { + // optional /* i'm a comment */ bool field = 1; + // } + + field := example.Fields[0] + assert.Equal(t, field.Name, "field") + assert.Equal(t, field.Type, "bool") + assert.True(t, field.IsOptional) +}