Source File
reset.go
Belonging Package
google.golang.org/protobuf/proto
// Copyright 2019 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 protoimport ()// Reset clears every field in the message.// The resulting message shares no observable memory with its previous state// other than the memory for the message itself.func ( Message) {if , := .(interface{ () }); && hasProtoMethods {.()return}resetMessage(.ProtoReflect())}func resetMessage( protoreflect.Message) {if !.IsValid() {panic(fmt.Sprintf("cannot reset invalid %v message", .Descriptor().FullName()))}// Clear all known fields.:= .Descriptor().Fields()for := 0; < .Len(); ++ {.Clear(.Get())}// Clear extension fields..Range(func( protoreflect.FieldDescriptor, protoreflect.Value) bool {.Clear()return true})// Clear unknown fields..SetUnknown(nil)}
![]() |
The pages are generated with Golds v0.8.2. (GOOS=linux GOARCH=amd64) Golds is a Go 101 project developed by Tapir Liu. PR and bug reports are welcome and can be submitted to the issue list. Please follow @zigo_101 (reachable from the left QR code) to get the latest news of Golds. |