mirror of
https://github.com/cloudflare/cloudflared.git
synced 2025-07-28 07:09:57 +00:00
TUN-9016: update go to 1.24
## Summary Update several moving parts of cloudflared build system: * use goboring 1.24.2 in cfsetup * update linter and fix lint issues * update packages namely **quic-go and net** * install script for macos * update docker files to use go 1.24.1 * remove usage of cloudflare-go * pin golang linter Closes TUN-9016
This commit is contained in:
21
vendor/google.golang.org/protobuf/proto/decode.go
generated
vendored
21
vendor/google.golang.org/protobuf/proto/decode.go
generated
vendored
@@ -8,7 +8,6 @@ import (
|
||||
"google.golang.org/protobuf/encoding/protowire"
|
||||
"google.golang.org/protobuf/internal/encoding/messageset"
|
||||
"google.golang.org/protobuf/internal/errors"
|
||||
"google.golang.org/protobuf/internal/flags"
|
||||
"google.golang.org/protobuf/internal/genid"
|
||||
"google.golang.org/protobuf/internal/pragma"
|
||||
"google.golang.org/protobuf/reflect/protoreflect"
|
||||
@@ -47,6 +46,12 @@ type UnmarshalOptions struct {
|
||||
// RecursionLimit limits how deeply messages may be nested.
|
||||
// If zero, a default limit is applied.
|
||||
RecursionLimit int
|
||||
|
||||
//
|
||||
// NoLazyDecoding turns off lazy decoding, which otherwise is enabled by
|
||||
// default. Lazy decoding only affects submessages (annotated with [lazy =
|
||||
// true] in the .proto file) within messages that use the Opaque API.
|
||||
NoLazyDecoding bool
|
||||
}
|
||||
|
||||
// Unmarshal parses the wire-format message in b and places the result in m.
|
||||
@@ -104,6 +109,16 @@ func (o UnmarshalOptions) unmarshal(b []byte, m protoreflect.Message) (out proto
|
||||
if o.DiscardUnknown {
|
||||
in.Flags |= protoiface.UnmarshalDiscardUnknown
|
||||
}
|
||||
|
||||
if !allowPartial {
|
||||
// This does not affect how current unmarshal functions work, it just allows them
|
||||
// to record this for lazy the decoding case.
|
||||
in.Flags |= protoiface.UnmarshalCheckRequired
|
||||
}
|
||||
if o.NoLazyDecoding {
|
||||
in.Flags |= protoiface.UnmarshalNoLazyDecoding
|
||||
}
|
||||
|
||||
out, err = methods.Unmarshal(in)
|
||||
} else {
|
||||
o.RecursionLimit--
|
||||
@@ -156,10 +171,6 @@ func (o UnmarshalOptions) unmarshalMessageSlow(b []byte, m protoreflect.Message)
|
||||
var err error
|
||||
if fd == nil {
|
||||
err = errUnknown
|
||||
} else if flags.ProtoLegacy {
|
||||
if fd.IsWeak() && fd.Message().IsPlaceholder() {
|
||||
err = errUnknown // weak referent is not linked in
|
||||
}
|
||||
}
|
||||
|
||||
// Parse the field value.
|
||||
|
3
vendor/google.golang.org/protobuf/proto/encode.go
generated
vendored
3
vendor/google.golang.org/protobuf/proto/encode.go
generated
vendored
@@ -63,7 +63,8 @@ type MarshalOptions struct {
|
||||
// options (except for UseCachedSize itself).
|
||||
//
|
||||
// 2. The message and all its submessages have not changed in any
|
||||
// way since the Size call.
|
||||
// way since the Size call. For lazily decoded messages, accessing
|
||||
// a message results in decoding the message, which is a change.
|
||||
//
|
||||
// If either of these invariants is violated,
|
||||
// the results are undefined and may include panics or corrupted output.
|
||||
|
9
vendor/google.golang.org/protobuf/proto/equal.go
generated
vendored
9
vendor/google.golang.org/protobuf/proto/equal.go
generated
vendored
@@ -8,6 +8,7 @@ import (
|
||||
"reflect"
|
||||
|
||||
"google.golang.org/protobuf/reflect/protoreflect"
|
||||
"google.golang.org/protobuf/runtime/protoiface"
|
||||
)
|
||||
|
||||
// Equal reports whether two messages are equal,
|
||||
@@ -51,6 +52,14 @@ func Equal(x, y Message) bool {
|
||||
if mx.IsValid() != my.IsValid() {
|
||||
return false
|
||||
}
|
||||
|
||||
// Only one of the messages needs to implement the fast-path for it to work.
|
||||
pmx := protoMethods(mx)
|
||||
pmy := protoMethods(my)
|
||||
if pmx != nil && pmy != nil && pmx.Equal != nil && pmy.Equal != nil {
|
||||
return pmx.Equal(protoiface.EqualInput{MessageA: mx, MessageB: my}).Equal
|
||||
}
|
||||
|
||||
vx := protoreflect.ValueOfMessage(mx)
|
||||
vy := protoreflect.ValueOfMessage(my)
|
||||
return vx.Equal(vy)
|
||||
|
77
vendor/google.golang.org/protobuf/proto/extension.go
generated
vendored
77
vendor/google.golang.org/protobuf/proto/extension.go
generated
vendored
@@ -39,7 +39,49 @@ func ClearExtension(m Message, xt protoreflect.ExtensionType) {
|
||||
// If the field is unpopulated, it returns the default value for
|
||||
// scalars and an immutable, empty value for lists or messages.
|
||||
// It panics if xt does not extend m.
|
||||
func GetExtension(m Message, xt protoreflect.ExtensionType) interface{} {
|
||||
//
|
||||
// The type of the value is dependent on the field type of the extension.
|
||||
// For extensions generated by protoc-gen-go, the Go type is as follows:
|
||||
//
|
||||
// ╔═══════════════════╤═════════════════════════╗
|
||||
// ║ Go type │ Protobuf kind ║
|
||||
// ╠═══════════════════╪═════════════════════════╣
|
||||
// ║ bool │ bool ║
|
||||
// ║ int32 │ int32, sint32, sfixed32 ║
|
||||
// ║ int64 │ int64, sint64, sfixed64 ║
|
||||
// ║ uint32 │ uint32, fixed32 ║
|
||||
// ║ uint64 │ uint64, fixed64 ║
|
||||
// ║ float32 │ float ║
|
||||
// ║ float64 │ double ║
|
||||
// ║ string │ string ║
|
||||
// ║ []byte │ bytes ║
|
||||
// ║ protoreflect.Enum │ enum ║
|
||||
// ║ proto.Message │ message, group ║
|
||||
// ╚═══════════════════╧═════════════════════════╝
|
||||
//
|
||||
// The protoreflect.Enum and proto.Message types are the concrete Go type
|
||||
// associated with the named enum or message. Repeated fields are represented
|
||||
// using a Go slice of the base element type.
|
||||
//
|
||||
// If a generated extension descriptor variable is directly passed to
|
||||
// GetExtension, then the call should be followed immediately by a
|
||||
// type assertion to the expected output value. For example:
|
||||
//
|
||||
// mm := proto.GetExtension(m, foopb.E_MyExtension).(*foopb.MyMessage)
|
||||
//
|
||||
// This pattern enables static analysis tools to verify that the asserted type
|
||||
// matches the Go type associated with the extension field and
|
||||
// also enables a possible future migration to a type-safe extension API.
|
||||
//
|
||||
// Since singular messages are the most common extension type, the pattern of
|
||||
// calling HasExtension followed by GetExtension may be simplified to:
|
||||
//
|
||||
// if mm := proto.GetExtension(m, foopb.E_MyExtension).(*foopb.MyMessage); mm != nil {
|
||||
// ... // make use of mm
|
||||
// }
|
||||
//
|
||||
// The mm variable is non-nil if and only if HasExtension reports true.
|
||||
func GetExtension(m Message, xt protoreflect.ExtensionType) any {
|
||||
// Treat nil message interface as an empty message; return the default.
|
||||
if m == nil {
|
||||
return xt.InterfaceOf(xt.Zero())
|
||||
@@ -51,7 +93,36 @@ func GetExtension(m Message, xt protoreflect.ExtensionType) interface{} {
|
||||
// SetExtension stores the value of an extension field.
|
||||
// It panics if m is invalid, xt does not extend m, or if type of v
|
||||
// is invalid for the specified extension field.
|
||||
func SetExtension(m Message, xt protoreflect.ExtensionType, v interface{}) {
|
||||
//
|
||||
// The type of the value is dependent on the field type of the extension.
|
||||
// For extensions generated by protoc-gen-go, the Go type is as follows:
|
||||
//
|
||||
// ╔═══════════════════╤═════════════════════════╗
|
||||
// ║ Go type │ Protobuf kind ║
|
||||
// ╠═══════════════════╪═════════════════════════╣
|
||||
// ║ bool │ bool ║
|
||||
// ║ int32 │ int32, sint32, sfixed32 ║
|
||||
// ║ int64 │ int64, sint64, sfixed64 ║
|
||||
// ║ uint32 │ uint32, fixed32 ║
|
||||
// ║ uint64 │ uint64, fixed64 ║
|
||||
// ║ float32 │ float ║
|
||||
// ║ float64 │ double ║
|
||||
// ║ string │ string ║
|
||||
// ║ []byte │ bytes ║
|
||||
// ║ protoreflect.Enum │ enum ║
|
||||
// ║ proto.Message │ message, group ║
|
||||
// ╚═══════════════════╧═════════════════════════╝
|
||||
//
|
||||
// The protoreflect.Enum and proto.Message types are the concrete Go type
|
||||
// associated with the named enum or message. Repeated fields are represented
|
||||
// using a Go slice of the base element type.
|
||||
//
|
||||
// If a generated extension descriptor variable is directly passed to
|
||||
// SetExtension (e.g., foopb.E_MyExtension), then the value should be a
|
||||
// concrete type that matches the expected Go type for the extension descriptor
|
||||
// so that static analysis tools can verify type correctness.
|
||||
// This also enables a possible future migration to a type-safe extension API.
|
||||
func SetExtension(m Message, xt protoreflect.ExtensionType, v any) {
|
||||
xd := xt.TypeDescriptor()
|
||||
pv := xt.ValueOf(v)
|
||||
|
||||
@@ -78,7 +149,7 @@ func SetExtension(m Message, xt protoreflect.ExtensionType, v interface{}) {
|
||||
// It returns immediately if f returns false.
|
||||
// While iterating, mutating operations may only be performed
|
||||
// on the current extension field.
|
||||
func RangeExtensions(m Message, f func(protoreflect.ExtensionType, interface{}) bool) {
|
||||
func RangeExtensions(m Message, f func(protoreflect.ExtensionType, any) bool) {
|
||||
// Treat nil message interface as an empty message; nothing to range over.
|
||||
if m == nil {
|
||||
return
|
||||
|
8
vendor/google.golang.org/protobuf/proto/size.go
generated
vendored
8
vendor/google.golang.org/protobuf/proto/size.go
generated
vendored
@@ -12,11 +12,19 @@ import (
|
||||
)
|
||||
|
||||
// Size returns the size in bytes of the wire-format encoding of m.
|
||||
//
|
||||
// Note that Size might return more bytes than Marshal will write in the case of
|
||||
// lazily decoded messages that arrive in non-minimal wire format: see
|
||||
// https://protobuf.dev/reference/go/size/ for more details.
|
||||
func Size(m Message) int {
|
||||
return MarshalOptions{}.Size(m)
|
||||
}
|
||||
|
||||
// Size returns the size in bytes of the wire-format encoding of m.
|
||||
//
|
||||
// Note that Size might return more bytes than Marshal will write in the case of
|
||||
// lazily decoded messages that arrive in non-minimal wire format: see
|
||||
// https://protobuf.dev/reference/go/size/ for more details.
|
||||
func (o MarshalOptions) Size(m Message) int {
|
||||
// Treat a nil message interface as an empty message; nothing to output.
|
||||
if m == nil {
|
||||
|
80
vendor/google.golang.org/protobuf/proto/wrapperopaque.go
generated
vendored
Normal file
80
vendor/google.golang.org/protobuf/proto/wrapperopaque.go
generated
vendored
Normal file
@@ -0,0 +1,80 @@
|
||||
// Copyright 2024 The Go Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
package proto
|
||||
|
||||
// ValueOrNil returns nil if has is false, or a pointer to a new variable
|
||||
// containing the value returned by the specified getter.
|
||||
//
|
||||
// This function is similar to the wrappers (proto.Int32(), proto.String(),
|
||||
// etc.), but is generic (works for any field type) and works with the hasser
|
||||
// and getter of a field, as opposed to a value.
|
||||
//
|
||||
// This is convenient when populating builder fields.
|
||||
//
|
||||
// Example:
|
||||
//
|
||||
// hop := attr.GetDirectHop()
|
||||
// injectedRoute := ripb.InjectedRoute_builder{
|
||||
// Prefixes: route.GetPrefixes(),
|
||||
// NextHop: proto.ValueOrNil(hop.HasAddress(), hop.GetAddress),
|
||||
// }
|
||||
func ValueOrNil[T any](has bool, getter func() T) *T {
|
||||
if !has {
|
||||
return nil
|
||||
}
|
||||
v := getter()
|
||||
return &v
|
||||
}
|
||||
|
||||
// ValueOrDefault returns the protobuf message val if val is not nil, otherwise
|
||||
// it returns a pointer to an empty val message.
|
||||
//
|
||||
// This function allows for translating code from the old Open Struct API to the
|
||||
// new Opaque API.
|
||||
//
|
||||
// The old Open Struct API represented oneof fields with a wrapper struct:
|
||||
//
|
||||
// var signedImg *accountpb.SignedImage
|
||||
// profile := &accountpb.Profile{
|
||||
// // The Avatar oneof will be set, with an empty SignedImage.
|
||||
// Avatar: &accountpb.Profile_SignedImage{signedImg},
|
||||
// }
|
||||
//
|
||||
// The new Opaque API treats oneof fields like regular fields, there are no more
|
||||
// wrapper structs:
|
||||
//
|
||||
// var signedImg *accountpb.SignedImage
|
||||
// profile := &accountpb.Profile{}
|
||||
// profile.SetSignedImage(signedImg)
|
||||
//
|
||||
// For convenience, the Opaque API also offers Builders, which allow for a
|
||||
// direct translation of struct initialization. However, because Builders use
|
||||
// nilness to represent field presence (but there is no non-nil wrapper struct
|
||||
// anymore), Builders cannot distinguish between an unset oneof and a set oneof
|
||||
// with nil message. The above code would need to be translated with help of the
|
||||
// ValueOrDefault function to retain the same behavior:
|
||||
//
|
||||
// var signedImg *accountpb.SignedImage
|
||||
// return &accountpb.Profile_builder{
|
||||
// SignedImage: proto.ValueOrDefault(signedImg),
|
||||
// }.Build()
|
||||
func ValueOrDefault[T interface {
|
||||
*P
|
||||
Message
|
||||
}, P any](val T) T {
|
||||
if val == nil {
|
||||
return T(new(P))
|
||||
}
|
||||
return val
|
||||
}
|
||||
|
||||
// ValueOrDefaultBytes is like ValueOrDefault but for working with fields of
|
||||
// type []byte.
|
||||
func ValueOrDefaultBytes(val []byte) []byte {
|
||||
if val == nil {
|
||||
return []byte{}
|
||||
}
|
||||
return val
|
||||
}
|
Reference in New Issue
Block a user