summaryrefslogtreecommitdiff
path: root/findFilename.go
diff options
context:
space:
mode:
authorJeff Carr <[email protected]>2025-10-08 10:46:04 -0500
committerJeff Carr <[email protected]>2025-10-08 10:46:04 -0500
commit9302d70634c4625e5262c4c1dd6d10fed83f71b3 (patch)
tree5a2b3495ce28c5cab5d06b0686c6b5f86c8a2fa0 /findFilename.go
parent58f309bec46b355e5d74bb0ba9e7f2901c4782f8 (diff)
notsure. something about generate not quite workingv0.0.14
Diffstat (limited to 'findFilename.go')
-rw-r--r--findFilename.go8
1 files changed, 6 insertions, 2 deletions
diff --git a/findFilename.go b/findFilename.go
index 1b36f38..85ccbf4 100644
--- a/findFilename.go
+++ b/findFilename.go
@@ -1,12 +1,16 @@
package config
import (
+ "errors"
"fmt"
"google.golang.org/protobuf/proto"
"google.golang.org/protobuf/reflect/protoreflect"
)
+var ErrProtoNoVarName error = errors.New("name not in .proto")
+var ErrProtoVarNotString error = errors.New("name exists but is not a string")
+
// Gemini AI can help author some pretty good protobuf code.
// I never remember the syntax for 'reflect' on these things.
@@ -35,13 +39,13 @@ func GetFilename(pb proto.Message) (string, error) {
// 4. Check if the field was found. If not, return false.
if fieldDescriptor == nil {
- return "", fmt.Errorf("fieldDescriptor == nil")
+ return "", ErrProtoNoVarName
}
// 5. (Optional but recommended) Verify the field is a string type.
if fieldDescriptor.Kind() != protoreflect.StringKind {
// The field exists but is not a string, so we can't return it as one.
- return "", fmt.Errorf("The field exists but is not a string")
+ return "", ErrProtoVarNotString
}
// 6. If the field exists and is a string, get its value.