summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJeff Carr <[email protected]>2025-10-11 03:42:44 -0500
committerJeff Carr <[email protected]>2025-10-11 04:32:41 -0500
commit7d7672b57332f3f440dc7febe5a88dd0bce88344 (patch)
treeeeeef65425acc432c201756119018ab051e6560f
parent8662ccb4a5b65d4b1ec1da85426cce3fdccaf33b (diff)
walks the DebInfo I thinkv0.0.85v0.0.84
-rw-r--r--mirrorsSupport.go2
-rw-r--r--printDebInfo.go42
2 files changed, 36 insertions, 8 deletions
diff --git a/mirrorsSupport.go b/mirrorsSupport.go
index f9daa83..aade2b8 100644
--- a/mirrorsSupport.go
+++ b/mirrorsSupport.go
@@ -31,7 +31,7 @@ func (pb *Package) Print() {
log.Info("NEW PB END\n")
log.Info("Attempt to walk pb.DebInfo")
- if err := printDebInfoStrings(pb); err != nil {
+ if err := printDebInfoStrings(pb, true); err != nil {
log.Info("pb.walk error:", err)
}
diff --git a/printDebInfo.go b/printDebInfo.go
index 8bf61cc..f0d9337 100644
--- a/printDebInfo.go
+++ b/printDebInfo.go
@@ -3,13 +3,16 @@ package zoopb
import (
"fmt"
+ "go.wit.com/lib/config"
+ "go.wit.com/log"
"google.golang.org/protobuf/proto"
"google.golang.org/protobuf/reflect/protoreflect"
)
-// PrintDebInfoStrings finds a nested message named "debInfo", then iterates over
-// its fields, printing the name and value of any field that is a string.
-func printDebInfoStrings(pb proto.Message) error {
+// if the varname isn't in the proto msg, then it'll try to read
+// the same varname from the base message. This allows the
+// .proto file to define the print order of the fields
+func printDebInfoStrings(pb proto.Message, fallback bool) error {
// 1. Get the reflection interface for the top-level message.
msg := pb.ProtoReflect()
descriptor := msg.Descriptor()
@@ -42,19 +45,44 @@ func printDebInfoStrings(pb proto.Message) error {
debInfoDescriptor := debInfoMsg.Descriptor()
fields := debInfoDescriptor.Fields()
- fmt.Printf("--- Listing String Fields in '%s' --- \n", debInfoFieldDesc.Name())
+ if verbose {
+ fmt.Printf("--- Listing String Fields in '%s' --- \n", debInfoFieldDesc.Name())
+ }
foundStrings := false
for i := 0; i < fields.Len(); i++ {
fieldDesc := fields.Get(i)
// 6. Check if the field's kind is a string.
if fieldDesc.Kind() == protoreflect.StringKind {
+ var value string
+ var fieldName protoreflect.Name
// Get the value from the debInfo message object.
- value := debInfoMsg.Get(fieldDesc).String()
- fieldName := fieldDesc.Name()
+ value = debInfoMsg.Get(fieldDesc).String()
+ fieldName = fieldDesc.Name()
+ if value == "" {
+ if verbose {
+ log.Info(string(fieldName), "is blank")
+ }
+ newval, err := config.GetString(pb, string(fieldName))
+ if err != nil {
+ if verbose {
+ log.Info("GetString() failed", newval, err)
+ }
+ continue
+ } else {
+ if verbose {
+ log.Info("GetString() worked:", newval)
+ }
+ value = newval
+ }
+ }
+ if value == "" {
+ // still blank after backup lookup
+ continue
+ }
// Print the result.
- fmt.Printf("%s: \"%s\"\n", fieldName, value)
+ fmt.Printf("%s: \"%s\"\n", string(fieldName), value)
foundStrings = true
}
}