Skip to content

Commit

Permalink
all: fix typos
Browse files Browse the repository at this point in the history
Change-Id: I90c7beff6f065b9348d516ff2cd6d0bd0379d516
  • Loading branch information
NathanBaulch committed Dec 19, 2024
1 parent ce4fa19 commit f1f75cd
Show file tree
Hide file tree
Showing 73 changed files with 2,644 additions and 2,641 deletions.
2 changes: 1 addition & 1 deletion cmd/protoc-gen-go/internal_gengo/well_known_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -1024,7 +1024,7 @@ func genMessageKnownFunctions(g *protogen.GeneratedFile, f *fileInfo, m *message
g.P()

g.P("// hasPathPrefix is like strings.HasPrefix, but further checks for either")
g.P("// an exact matche or that the prefix is delimited by a dot.")
g.P("// an exact match or that the prefix is delimited by a dot.")
g.P("func hasPathPrefix(path, prefix string) bool {")
g.P(" return ", stringsPackage.Ident("HasPrefix"), "(path, prefix) && (len(path) == len(prefix) || path[len(prefix)] == '.')")
g.P("}")
Expand Down
4 changes: 2 additions & 2 deletions compiler/protogen/protogen_opaque.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ func opaqueNewMessageHook(message *Message) {
// New name mangling scheme: Add a '_' between method base
// name (Get, Set, Clear etc) and original field name if
// needed. As a special case, there is one globally reserved
// name, e.g. "Build" thet still results in actual renaming of
// name, e.g. "Build" that still results in actual renaming of
// the builder field like in the old scheme. We begin by
// taking care of this special case.
for _, field := range message.Fields {
Expand All @@ -45,7 +45,7 @@ func opaqueNewMessageHook(message *Message) {
camelCases[field.camelCase] = true

}
// For each field, check if any of it's methods would clash with an original field name
// For each field, check if any of its methods would clash with an original field name
for _, field := range message.Fields {
// Every field (except the union fields, that are taken care of separately) has
// a Get and a Set method.
Expand Down
2 changes: 1 addition & 1 deletion encoding/protojson/encode.go
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@ func (m unpopulatedFieldRanger) Range(f func(protoreflect.FieldDescriptor, proto
for i := 0; i < fds.Len(); i++ {
fd := fds.Get(i)
if m.Has(fd) || fd.ContainingOneof() != nil {
continue // ignore populated fields and fields within a oneofs
continue // ignore populated fields and fields within a oneof
}

v := m.Get(fd)
Expand Down
4 changes: 2 additions & 2 deletions encoding/protojson/fuzz_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,12 +64,12 @@ func roundTripAndCompareProto(t *testing.T, wireBytes []byte, messages ...proto.

jsonBytes, err := protojson.Marshal(src)
if err != nil {
t.Errorf("failed to marshal messsage to json: %v\nmessage: %v", err, src)
t.Errorf("failed to marshal message to json: %v\nmessage: %v", err, src)
}
dst := msg.ProtoReflect().Type().New().Interface()

if err := protojson.Unmarshal(jsonBytes, dst); err != nil {
t.Errorf("failed to unmarshal messsage from json: %v\njson: %s", err, jsonBytes)
t.Errorf("failed to unmarshal message from json: %v\njson: %s", err, jsonBytes)
}

// The cmp package does not deal with NaN on its own and will report
Expand Down
2 changes: 1 addition & 1 deletion encoding/protojson/well_known_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ func wellKnownTypeMarshaler(name protoreflect.FullName) marshalFunc {

type unmarshalFunc func(decoder, protoreflect.Message) error

// wellKnownTypeUnmarshaler returns a unmarshal function if the message type
// wellKnownTypeUnmarshaler returns an unmarshal function if the message type
// has specialized serialization behavior. It returns nil otherwise.
func wellKnownTypeUnmarshaler(name protoreflect.FullName) unmarshalFunc {
if name.Parent() == genid.GoogleProtobuf_package {
Expand Down
4 changes: 2 additions & 2 deletions encoding/prototext/fuzz_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,12 +64,12 @@ func roundTripAndCompareProto(t *testing.T, wireBytes []byte, messages ...proto.

textFormat, err := prototext.Marshal(src)
if err != nil {
t.Errorf("failed to marshal messsage to text format: %v\nmessage: %v", err, src)
t.Errorf("failed to marshal message to text format: %v\nmessage: %v", err, src)
}
dst := msg.ProtoReflect().Type().New().Interface()

if err := (prototext.Unmarshal(textFormat, dst)); err != nil {
t.Errorf("failed to unmarshal messsage from text format: %v\ntext format: %s", err, textFormat)
t.Errorf("failed to unmarshal message from text format: %v\ntext format: %s", err, textFormat)
}

// The cmp package does not deal with NaN on its own and will report
Expand Down
2 changes: 1 addition & 1 deletion encoding/protowire/wire_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ type (
}
appendRaw []byte

// consumeOp represents an Consume operation.
// consumeOp represents a Consume operation.
consumeOp = any
consumeField struct {
wantNum Number
Expand Down
2 changes: 1 addition & 1 deletion internal/cmd/generate-protos/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -421,7 +421,7 @@ func generateRemoteProtos() {

// Benchmark protos.
// TODO: The protobuf repo no longer includes benchmarks.
// CL removing them says they are superceded by google/fleetbench:
// CL removing them says they are superseded by google/fleetbench:
// https://github.com/protocolbuffers/protobuf/commit/83c499de86224538e5d59adc3d0fa7fdb45b2c72
// But that project's proto benchmark files are very different:
// https://github.com/google/fleetbench/tree/main/fleetbench/proto
Expand Down
4 changes: 2 additions & 2 deletions internal/cmd/generate-types/proto.go
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ func (g GoType) NullableStar() Expr {
return "*"
}

// OpaqueNullablePointerMethod is the "internal/impl".pointer method used to access a opaque nullable pointer to this type.
// OpaqueNullablePointerMethod is the "internal/impl".pointer method used to access an opaque nullable pointer to this type.
func (g GoType) OpaqueNullablePointerMethod() Expr {
switch g {
case GoString:
Expand All @@ -117,7 +117,7 @@ func (g GoType) OpaqueNullablePointerMethod() Expr {

}

// OpaqueNullableStar is the prefix for dereferencing a opaque nullable value of this type.
// OpaqueNullableStar is the prefix for dereferencing an opaque nullable value of this type.
func (g GoType) OpaqueNullableStar() Expr {
if g == GoString {
return "*" // Strings have indirection even in opaque
Expand Down
4 changes: 2 additions & 2 deletions internal/conformance/failing_tests_text_format.txt
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
Recommended.Editions_Proto3.ProtobufInput.MessageUnknownFields_Print.TextFormatOutput # TEXT_FORMAT output we received from test was unparseable.
Recommended.Editions_Proto3.ProtobufInput.MessageUnknownFields_Print.TextFormatOutput # TEXT_FORMAT output we received from test was unparsable.
Recommended.Editions_Proto3.TextFormatInput.StringLiteralShortUnicodeEscapeSurrogatePairBytes # Should have failed to parse, but didn't.
Recommended.Editions_Proto3.TextFormatInput.StringLiteralShortUnicodeEscapeSurrogatePairString # Should have failed to parse, but didn't.
Recommended.Editions_Proto3.TextFormatInput.StringLiteralUnicodeEscapeSurrogatePairLongShortBytes # Should have failed to parse, but didn't.
Recommended.Editions_Proto3.TextFormatInput.StringLiteralUnicodeEscapeSurrogatePairLongShortString # Should have failed to parse, but didn't.
Recommended.Proto3.ProtobufInput.MessageUnknownFields_Print.TextFormatOutput # TEXT_FORMAT output we received from test was unparseable.
Recommended.Proto3.ProtobufInput.MessageUnknownFields_Print.TextFormatOutput # TEXT_FORMAT output we received from test was unparsable.
Recommended.Proto3.TextFormatInput.StringLiteralShortUnicodeEscapeSurrogatePairBytes # Should have failed to parse, but didn't.
Recommended.Proto3.TextFormatInput.StringLiteralShortUnicodeEscapeSurrogatePairString # Should have failed to parse, but didn't.
Recommended.Proto3.TextFormatInput.StringLiteralUnicodeEscapeSurrogatePairLongShortBytes # Should have failed to parse, but didn't.
Expand Down
2 changes: 1 addition & 1 deletion internal/encoding/tag/tag.go
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ func Marshal(fd protoreflect.FieldDescriptor, enumName string) string {
}
tag = append(tag, "name="+name)
if jsonName := fd.JSONName(); jsonName != "" && jsonName != name && !fd.IsExtension() {
// NOTE: The jsonName != name condition is suspect, but it preserve
// NOTE: The jsonName != name condition is suspect, but it preserves
// the exact same semantics from the previous generator.
tag = append(tag, "json="+jsonName)
}
Expand Down
2 changes: 1 addition & 1 deletion internal/encoding/text/decode.go
Original file line number Diff line number Diff line change
Expand Up @@ -335,7 +335,7 @@ func (d *Decoder) parseNext(lastKind Kind) (Token, error) {

case ListOpen:
if lastKind == semicolon {
// It is not be possible to have this case as logic here
// It is not possible to have this case as logic here
// should not have produced a semicolon Token when inside a
// list. Let it panic below.
break
Expand Down
2 changes: 1 addition & 1 deletion internal/encoding/text/decode_number.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ type number struct {
neg bool
size int
// if neg, this is the length of whitespace and comments between
// the minus sign and the rest fo the number literal
// the minus sign and the rest of the number literal
sep int
}

Expand Down
2 changes: 1 addition & 1 deletion internal/encoding/text/decode_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -526,7 +526,7 @@ func TestDecoder(t *testing.T) {
},
},
{
// Whitespaces/comments are only allowed betweeb
// Whitespaces/comments are only allowed between
in: "[" + space + "domain" + space + "." + space + "com # comment\n" +
"/" + "pkg" + space + "." + space + "type" + space + "]",
want: []R{
Expand Down
4 changes: 2 additions & 2 deletions internal/filedesc/build.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
// Package filedesc provides functionality for constructing descriptors.
//
// The types in this package implement interfaces in the protoreflect package
// related to protobuf descripriptors.
// related to protobuf descriptors.
package filedesc

import (
Expand Down Expand Up @@ -40,7 +40,7 @@ type Builder struct {
protoregistry.ExtensionTypeResolver
}

// FileRegistry is use to lookup file, enum, and message dependencies.
// FileRegistry is used to lookup file, enum, and message dependencies.
// Once constructed, the file descriptor is registered here.
// If nil, it uses protoregistry.GlobalFiles.
FileRegistry interface {
Expand Down
6 changes: 3 additions & 3 deletions internal/filedesc/editions.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ func unmarshalGoFeature(b []byte, parent EditionFeatures) EditionFeatures {
b = b[m:]
parent.StripEnumPrefix = int(v)
default:
panic(fmt.Sprintf("unkown field number %d while unmarshalling GoFeatures", num))
panic(fmt.Sprintf("unknown field number %d while unmarshalling GoFeatures", num))
}
}
return parent
Expand Down Expand Up @@ -70,7 +70,7 @@ func unmarshalFeatureSet(b []byte, parent EditionFeatures) EditionFeatures {
case genid.FeatureSet_JsonFormat_field_number:
parent.IsJSONCompliant = v == genid.FeatureSet_ALLOW_enum_value
default:
panic(fmt.Sprintf("unkown field number %d while unmarshalling FeatureSet", num))
panic(fmt.Sprintf("unknown field number %d while unmarshalling FeatureSet", num))
}
case protowire.BytesType:
v, m := protowire.ConsumeBytes(b)
Expand Down Expand Up @@ -144,7 +144,7 @@ func unmarshalEditionDefaults(b []byte) {
_, m := protowire.ConsumeVarint(b)
b = b[m:]
default:
panic(fmt.Sprintf("unkown field number %d while unmarshalling EditionDefault", num))
panic(fmt.Sprintf("unknown field number %d while unmarshalling EditionDefault", num))
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion internal/impl/api_export_opaque.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ func (Export) UnmarshalField(msg any, fieldNum int32) {
// &m.XXX_presence[1], num = 70)
func (Export) Present(part *uint32, num uint32) bool {
// This hook will read an unprotected shadow presence set if
// we're unning under the race detector
// we're running under the race detector
raceDetectHookPresent(part, num)
return atomic.LoadUint32(part)&(1<<(num%32)) > 0
}
Expand Down
2 changes: 1 addition & 1 deletion internal/impl/codec_extension.go
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ func (f *ExtensionField) canLazy(xt protoreflect.ExtensionType) bool {
return false
}

// isUnexpandedLazy returns true if the ExensionField is lazy and not
// isUnexpandedLazy returns true if the ExtensionField is lazy and not
// yet expanded, which means it's present and already checked for
// initialized required fields.
func (f *ExtensionField) isUnexpandedLazy() bool {
Expand Down
2 changes: 1 addition & 1 deletion internal/impl/lazy_buffersharing_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ func testNoExcessiveCopy(t *testing.T, unmarshalOpts proto.UnmarshalOptions) {
}
b = (*m3.XXX_lazyUnmarshalInfo).Protobuf
if m2len != 0 && len(b) == 0 {
t.Errorf("The lazy backing store for submessage is empty when it is not for the surronding message: %v.", m2len)
t.Errorf("The lazy backing store for submessage is empty when it is not for the surrounding message: %v.", m2len)
}
for i, x := range b {
if x != byte(0xFF) {
Expand Down
12 changes: 6 additions & 6 deletions internal/impl/lazy_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ func TestExtensionLazy(t *testing.T) {

fox := proto.GetExtension(nt, lazytestpb.E_Bat).(*lazytestpb.FlyingFox)
if got, want := fox.GetSpecies(), spGH; want != got {
t.Errorf("Extension's Speices field not retained, want: %v, got: %v", want, got)
t.Errorf("Extension's Species field not retained, want: %v, got: %v", want, got)
}
if got, want := extensionIsInitialized(t, nt, lazytestpb.E_Bat.Field), true; got != want {
t.Errorf("Extension unexpectedly initialized after Get")
Expand All @@ -164,7 +164,7 @@ func TestExtensionLazy(t *testing.T) {
}
foxPup := proto.GetExtension(nt, lazytestpb.E_BatPup).(*lazytestpb.FlyingFox)
if got, want := foxPup.GetSpecies(), spP; want != got {
t.Errorf("Extension's Speices field not retained, want: %v, got: %v", want, got)
t.Errorf("Extension's Species field not retained, want: %v, got: %v", want, got)
}
if got, want := extensionIsInitialized(t, nt, lazytestpb.E_Bat.Field), true; got != want {
t.Errorf("Extension unexpectedly initialized after Get")
Expand Down Expand Up @@ -226,7 +226,7 @@ func TestExtensionNestedScopeLazy(t *testing.T) {

fox := proto.GetExtension(nt, lazytestpb.E_BatNest_Bat).(*lazytestpb.FlyingFox)
if got, want := fox.GetSpecies(), spGH; want != got {
t.Errorf("Extension's Speices field not retained, want: %v, got: %v", want, got)
t.Errorf("Extension's Species field not retained, want: %v, got: %v", want, got)
}
if got, want := extensionIsInitialized(t, nt, lazytestpb.E_BatNest_Bat.Field), true; got != want {
t.Errorf("Extension unexpectedly initialized after Get")
Expand Down Expand Up @@ -277,7 +277,7 @@ func TestExtensionRepeatedMessageLazy(t *testing.T) {
mrr = roundtrip(t, mr).(*lazytestpb.Tree)
foxPosse := proto.GetExtension(mrr, lazytestpb.E_BatPosse).([]*lazytestpb.FlyingFox)
if got, want := foxPosse[0].GetSpecies(), spLE; got != want {
t.Errorf("Extension's Speices field, want: %v, got: %v", want, got)
t.Errorf("Extension's Species field, want: %v, got: %v", want, got)
}
if got, want := extensionIsInitialized(t, mrr, lazytestpb.E_BatPosse.Field), true; got != want {
t.Errorf("Extension unexpectedly initialized after Get")
Expand Down Expand Up @@ -424,7 +424,7 @@ func TestExtensionGroupLazy(t *testing.T) {
}
pipistrelle := proto.GetExtension(mrr, lazytestpb.E_Pipistrelle).(*lazytestpb.Pipistrelle)
if got, want := pipistrelle.GetSpecies(), spF; got != want {
t.Errorf("Extension's Speices field, want: %v, got: %v", want, got)
t.Errorf("Extension's Species field, want: %v, got: %v", want, got)
}
if got, want := extensionIsInitialized(t, mrr, lazytestpb.E_Pipistrelle.Field), true; got != want {
t.Errorf("Extension unexpectedly initialized after Get")
Expand Down Expand Up @@ -458,7 +458,7 @@ func TestExtensionGroupLazy(t *testing.T) {
mrr = roundtrip(t, mr).(*lazytestpb.Tree)
pipistrelles := proto.GetExtension(mrr, lazytestpb.E_Pipistrelles).([]*lazytestpb.Pipistrelles)
if got, want := pipistrelles[1].GetSpecies(), spR; got != want {
t.Errorf("Extension's Speices field, want: %v, got: %v", want, got)
t.Errorf("Extension's Species field, want: %v, got: %v", want, got)
}
if got, want := extensionIsInitialized(t, mrr, lazytestpb.E_Pipistrelles.Field), true; got != want {
t.Errorf("Extension unexpectedly initialized after Get")
Expand Down
2 changes: 1 addition & 1 deletion internal/impl/legacy_enum.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ func legacyEnumName(ed protoreflect.EnumDescriptor) string {
}

// legacyWrapEnum wraps v as a protoreflect.Enum,
// where v must be a int32 kind and not implement the v2 API already.
// where v must be an int32 kind and not implement the v2 API already.
func legacyWrapEnum(v reflect.Value) protoreflect.Enum {
et := legacyLoadEnumType(v.Type())
return et.New(protoreflect.EnumNumber(v.Int()))
Expand Down
4 changes: 2 additions & 2 deletions internal/impl/presence.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ func (p presence) ClearPresent(num uint32) {
// LoadPresenceCache (together with PresentInCache) allows for a
// cached version of checking for presence without re-reading the word
// for every field. It is optimized for efficiency and assumes no
// simltaneous mutation of the presence set (or at least does not have
// simultaneous mutation of the presence set (or at least does not have
// a problem with simultaneous mutation giving inconsistent results).
func (p presence) LoadPresenceCache() (current uint32) {
if p.P == nil {
Expand Down Expand Up @@ -123,7 +123,7 @@ func atomicStoreShadowPresence(p **[]byte, v *[]byte) {

// findPointerToRaceDetectData finds the preceding RaceDetectHookData
// in a message by using pointer arithmetic. For the methods called
// directy from generated code, we don't have a pointer to the
// directly from generated code, we don't have a pointer to the
// beginning of the presence set, but a pointer inside the array. As
// we know the index of the bit we're manipulating (num), we can
// calculate which element of the array ptr is pointing to. With that
Expand Down
2 changes: 1 addition & 1 deletion internal/order/range.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ var messageFieldPool = sync.Pool{
}

type (
// FieldRnger is an interface for visiting all fields in a message.
// FieldRanger is an interface for visiting all fields in a message.
// The protoreflect.Message type implements this interface.
FieldRanger interface{ Range(VisitField) }
// VisitField is called every time a message field is visited.
Expand Down
2 changes: 1 addition & 1 deletion internal/protolazy/bufferreader.go
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,7 @@ func (b *BufferReader) SkipGroup(tag uint32) (err error) {
return nil
}

// skipVarint effiently skips a varint
// skipVarint efficiently skips a varint
func (b *BufferReader) SkipVarint() (err error) {
i := b.Pos

Expand Down
4 changes: 2 additions & 2 deletions internal/protolazy/lazy.go
Original file line number Diff line number Diff line change
Expand Up @@ -323,8 +323,8 @@ func (lazy *XXX_lazyUnmarshalInfo) FindFieldInProto(fieldNum uint32) (start, end
// a repeated field), and bools indicating if field was found and if there
// are multiple encodings of the field in the byte range.
//
// To hande the uncommon case where there are repeated encodings for the same
// field which are not consecutive in the protobuf (so we need to returns
// To handle the uncommon case where there are repeated encodings for the same
// field which are not consecutive in the protobuf (so we need to return
// multiple start/end offsets), we also return a slice multipleEntries. If
// multipleEntries is non-nil, then multiple entries were found, and the
// values in the slice should be used, rather than start/end/found.
Expand Down
12 changes: 6 additions & 6 deletions internal/race_test/lazy/lazy_race_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ func spawnCase(t *testing.T) {
t.Fatalf("Failed to find my own executable: %v", err)
}
c := exec.Command(ep, "--test.run="+t.Name())
// Set the environment variable so that we know we're in a subproceess when re-executed
// Set the environment variable so that we know we're in a subprocess when re-executed
c.Env = append(c.Env, envVar+"=true")
out, err := c.CombinedOutput()
// If we do not get an error, we fail in the parent process, otherwise we're good
Expand Down Expand Up @@ -310,9 +310,9 @@ func expandedLazy(m *testopaquepb.TestRequiredLazy) bool {
return rf.Pointer() != 0
}

// This test verifies all assumptions of TestParallellMarshalWithRequired
// This test verifies all assumptions of TestParallelMarshalWithRequired
// are (still) valid, to prevent the test from becoming a no-op (again).
func TestParallellMarshalWithRequiredAssumptions(t *testing.T) {
func TestParallelMarshalWithRequiredAssumptions(t *testing.T) {
b, err := proto.Marshal(fillRequiredLazy())
if err != nil {
t.Fatal(err)
Expand Down Expand Up @@ -347,12 +347,12 @@ func TestParallellMarshalWithRequiredAssumptions(t *testing.T) {
}
}

// TestParallellMarshalWithRequired runs two goroutines that marshal the same
// TestParallelMarshalWithRequired runs two goroutines that marshal the same
// message. Marshaling a message can result in lazily decoding said message,
// provided the message contains any required fields. This test ensures that
// said lazy decoding can happen without causing races in the other goroutine
// that marshals the same message.
func TestParallellMarshalWithRequired(t *testing.T) {
func TestParallelMarshalWithRequired(t *testing.T) {
m := fillRequiredLazy()
b, err := proto.MarshalOptions{}.Marshal(m)
if err != nil {
Expand Down Expand Up @@ -432,7 +432,7 @@ func fillMixedOpaqueLazy() *mixedpb.OpaqueLazy {
}.Build()
}

func TestParallellMarshalMixed(t *testing.T) {
func TestParallelMarshalMixed(t *testing.T) {
m := fillMixedOpaqueLazy()
b, err := proto.Marshal(m)
if err != nil {
Expand Down
Loading

0 comments on commit f1f75cd

Please sign in to comment.