aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMartin Czygan <martin.czygan@gmail.com>2021-06-04 00:36:44 +0200
committerMartin Czygan <martin.czygan@gmail.com>2021-06-04 00:36:44 +0200
commit7f45068e885424f001391c8bf54d99b8d4aa01c8 (patch)
treec8c1a8753ed390d7fbb5a697918dc802ec71bc18
parentd31b54d4c16c4a79be10817cfdc666f7f8601b40 (diff)
downloadrefcat-7f45068e885424f001391c8bf54d99b8d4aa01c8.tar.gz
refcat-7f45068e885424f001391c8bf54d99b8d4aa01c8.zip
find by prefix
-rw-r--r--skate/zippy.go13
1 files changed, 12 insertions, 1 deletions
diff --git a/skate/zippy.go b/skate/zippy.go
index 65155e8..8e629bf 100644
--- a/skate/zippy.go
+++ b/skate/zippy.go
@@ -186,10 +186,11 @@ func ZippyVerifyRefsOpenLibraryTable(olr, refs io.Reader, w io.Writer) error {
// compare against titles from open library.
re.Title = re.ContainerName
result := Verify(pivot, re)
- fmt.Printf("%s\t%s\t%s\t%s\t%s\t%s\t%s\n",
+ fmt.Printf("%s\t%s\t%s\t%s\t%s\t%s\t%s\t%s\n",
result.Status.Short(),
result.Reason.Short(),
pivot.Extra.OpenLibrary.WorkID,
+ FindByPrefix(pivot.Extra.OpenLibrary.SourceRecords, "ia:"),
re.Ident,
CutSep(g.G0[0], "\t", 1),
pivot.Title,
@@ -218,6 +219,16 @@ func CutSep(line, sep string, column int) string {
}
}
+// FindByPrefix return the first element for a slice of strings, which matches a prefix.
+func FindByPrefix(ss []string, prefix string) string {
+ for _, s := range ss {
+ if strings.HasPrefix(s, prefix) {
+ return s
+ }
+ }
+ return ""
+}
+
// makeKeyFunc creates a function that can be used as keyFunc, selecting a
// column from fields separated by sep; column is 1-indexed.
func makeKeyFunc(sep string, column int) func(string) (string, error) {