Skip to content

Commit

Permalink
Force usage of private/pkg/protoencoding for text and yaml (#3347)
Browse files Browse the repository at this point in the history
  • Loading branch information
emcfarlane authored Sep 26, 2024
1 parent c851732 commit b8aeca1
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 10 deletions.
28 changes: 20 additions & 8 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,10 @@ linters-settings:
- '^print$'
- '^println$'
# Use private/pkg/protoencoding Marshalers and Unmarshalers
- '^proto.Marshal$'
- '^proto.Unmarshal$'
- '^proto.MarshalOptions$'
- '^proto.UnmarshalOptions$'
- '^protojson.Marshal$'
- '^protojson.Unmarshal$'
- '^protojson.MarshalOptions$'
- '^protojson.UnmarshalOptions$'
- '^(proto|prototext|protojson|protoyaml).Marshal$'
- '^(proto|prototext|protojson|protoyaml).Unmarshal$'
- '^(proto|prototext|protojson|protoyaml).MarshalOptions$'
- '^(proto|prototext|protojson|protoyaml).UnmarshalOptions$'
govet:
enable:
- nilness
Expand Down Expand Up @@ -378,3 +374,19 @@ issues:
- forbidigo
path: private/pkg/protoencoding
text: "protojson.Unmarshal"
- linters:
- forbidigo
path: private/pkg/protoencoding
text: "protoyaml.Marshal"
- linters:
- forbidigo
path: private/pkg/protoencoding
text: "protoyaml.Unmarshal"
- linters:
- forbidigo
path: private/pkg/protoencoding
text: "prototext.Marshal"
- linters:
- forbidigo
path: private/pkg/protoencoding
text: "prototext.Unmarshal"
4 changes: 2 additions & 2 deletions private/buf/bufcurl/invoker_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,10 @@ import (
"os"
"testing"

"github.com/bufbuild/buf/private/pkg/protoencoding"
"github.com/bufbuild/protocompile"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"google.golang.org/protobuf/encoding/prototext"
"google.golang.org/protobuf/reflect/protoreflect"
)

Expand All @@ -39,7 +39,7 @@ func TestCountUnrecognized(t *testing.T) {
msg := msgType.New()
msgData, err := os.ReadFile("./testdata/testdata.txt")
require.NoError(t, err)
err = prototext.Unmarshal(msgData, msg.Interface())
err = protoencoding.NewTxtpbUnmarshaler(nil).Unmarshal(msgData, msg.Interface())
require.NoError(t, err)
// Add some unrecognized bytes
unknownBytes := []byte{0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 1}
Expand Down

0 comments on commit b8aeca1

Please sign in to comment.