summaryrefslogtreecommitdiff
path: root/find.go
diff options
context:
space:
mode:
Diffstat (limited to 'find.go')
-rw-r--r--find.go25
1 files changed, 25 insertions, 0 deletions
diff --git a/find.go b/find.go
new file mode 100644
index 0000000..6f876c0
--- /dev/null
+++ b/find.go
@@ -0,0 +1,25 @@
+package zoopb
+
+import (
+ "errors"
+)
+
+func (m *Machine) FindByPackageName(name string) (*Package, error) {
+ return m.Packages.FindByPackageName(name)
+}
+
+// used when you want to inforce the protobuf only has one package per name
+func (all *Packages) FindByPackageName(name string) (*Package, error) {
+ var found *Package
+ for p := range all.IterByPackage() {
+ if name == p.Package {
+ if found != nil {
+ return found, errors.New("duplicate package names in protobuf")
+ }
+ found = p
+ }
+ }
+
+ // log.Info("package name not found", name)
+ return found, nil
+}