diff options
| author | Jeff Carr <[email protected]> | 2025-10-08 10:47:54 -0500 |
|---|---|---|
| committer | Jeff Carr <[email protected]> | 2025-10-08 10:47:54 -0500 |
| commit | 856825033081b57cb6beb1944c83ce675a792f93 (patch) | |
| tree | b0ae3c35966b5803276b2c5056b9e15e6cf10325 /populatePackagePB.go | |
| parent | 9bae8cd3a70f1049385e3c25696a6f578db5bb97 (diff) | |
try to fill Package.pbv0.0.4
Diffstat (limited to 'populatePackagePB.go')
| -rw-r--r-- | populatePackagePB.go | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/populatePackagePB.go b/populatePackagePB.go index 10fb4f2..6bd3c48 100644 --- a/populatePackagePB.go +++ b/populatePackagePB.go @@ -3,9 +3,11 @@ package debian import ( "google.golang.org/protobuf/proto" "google.golang.org/protobuf/reflect/protoreflect" + + "go.wit.com/lib/config" ) -func setString(pb proto.Message, varname string, val string) bool { +func setString(pb proto.Message, varname string, val string) (bool, error) { msg := pb.ProtoReflect() // This is the entry point to the reflection API. descriptor := msg.Descriptor() // Get the message's descriptor, which contains metadata about its fields. @@ -14,12 +16,12 @@ func setString(pb proto.Message, varname string, val string) bool { fieldDescriptor := descriptor.Fields().ByName(fieldName) if fieldDescriptor == nil { - return false + return false, config.ErrProtoNoVarName } if fieldDescriptor.Kind() != protoreflect.StringKind { // The field exists but is not a string, so we can't return it as one. - return false + return false, config.ErrProtoVarNotString } valueToSet := protoreflect.ValueOfString(varname) @@ -29,5 +31,5 @@ func setString(pb proto.Message, varname string, val string) bool { msg.Set(fieldDescriptor, valueToSet) // 7. Convert the protoreflect.Value to a native Go string. - return true + return true, nil } |
