aboutsummaryrefslogtreecommitdiffstats
path: root/skate/schema.go
diff options
context:
space:
mode:
Diffstat (limited to 'skate/schema.go')
-rw-r--r--skate/schema.go64
1 files changed, 32 insertions, 32 deletions
diff --git a/skate/schema.go b/skate/schema.go
index d6b4ded..b69f206 100644
--- a/skate/schema.go
+++ b/skate/schema.go
@@ -128,75 +128,75 @@ func RefToRelease(ref *Ref) (*Release, error) {
// try to be readable.
func ReleaseToUnstructured(r *Release) string {
var (
- buf bytes.Buffer
+ sb strings.Builder
names = make([]string, len(r.Contribs))
)
for i := 0; i < len(r.Contribs); i++ {
names[i] = r.Contribs[i].RawName
}
- fmt.Fprintf(&buf, "%s", strings.Join(names, ", "))
+ fmt.Fprintf(&sb, "%s", strings.Join(names, ", "))
if r.Title != "" {
- if buf.Len() > 0 {
- fmt.Fprintf(&buf, ". ")
+ if sb.Len() > 0 {
+ fmt.Fprintf(&sb, ". ")
}
- fmt.Fprintf(&buf, `%s`, r.Title)
+ fmt.Fprintf(&sb, `%s`, r.Title)
}
if len(r.Subtitle()) > 0 {
- fmt.Fprintf(&buf, ": %s", strings.Join(r.Subtitle(), " "))
+ fmt.Fprintf(&sb, ": %s", strings.Join(r.Subtitle(), " "))
}
if r.ContainerName != "" {
- if buf.Len() > 0 {
- fmt.Fprintf(&buf, ". ")
+ if sb.Len() > 0 {
+ fmt.Fprintf(&sb, ". ")
}
- fmt.Fprintf(&buf, `%s`, r.ContainerName)
+ fmt.Fprintf(&sb, `%s`, r.ContainerName)
}
if r.Volume != "" {
- if buf.Len() > 0 {
- fmt.Fprintf(&buf, ", ")
+ if sb.Len() > 0 {
+ fmt.Fprintf(&sb, ", ")
}
- fmt.Fprintf(&buf, `vol. %s`, r.Volume)
+ fmt.Fprintf(&sb, `vol. %s`, r.Volume)
}
if r.Issue != "" {
- if buf.Len() > 0 {
- fmt.Fprintf(&buf, ", ")
+ if sb.Len() > 0 {
+ fmt.Fprintf(&sb, ", ")
}
- fmt.Fprintf(&buf, `no. %s`, r.Issue)
+ fmt.Fprintf(&sb, `no. %s`, r.Issue)
}
if r.ReleaseYear() > 0 {
- if buf.Len() > 0 {
- fmt.Fprintf(&buf, ", ")
+ if sb.Len() > 0 {
+ fmt.Fprintf(&sb, ", ")
}
- fmt.Fprintf(&buf, `%s`, r.ReleaseYearString())
+ fmt.Fprintf(&sb, `%s`, r.ReleaseYearString())
}
if r.Pages != "" {
- if buf.Len() > 0 {
- fmt.Fprintf(&buf, ", ")
+ if sb.Len() > 0 {
+ fmt.Fprintf(&sb, ", ")
}
- fmt.Fprintf(&buf, `pp. %s`, r.Pages)
+ fmt.Fprintf(&sb, `pp. %s`, r.Pages)
}
if r.Publisher != "" {
- if buf.Len() > 0 {
- fmt.Fprintf(&buf, ", ")
+ if sb.Len() > 0 {
+ fmt.Fprintf(&sb, ", ")
}
- fmt.Fprintf(&buf, `%s`, r.Publisher)
+ fmt.Fprintf(&sb, `%s`, r.Publisher)
}
switch {
case r.ExtIDs.DOI != "":
- if buf.Len() > 0 {
- fmt.Fprintf(&buf, ", ")
+ if sb.Len() > 0 {
+ fmt.Fprintf(&sb, ", ")
}
- fmt.Fprintf(&buf, `%s`, r.ExtIDs.DOI)
+ fmt.Fprintf(&sb, `%s`, r.ExtIDs.DOI)
case len(r.ExtIDs.ISBN) > 0:
- if buf.Len() > 0 {
- fmt.Fprintf(&buf, ", ")
+ if sb.Len() > 0 {
+ fmt.Fprintf(&sb, ", ")
}
if isbn13, err := isbn.To13(r.ExtIDs.ISBN[0]); err == nil {
- fmt.Fprintf(&buf, `%s`, isbn13)
+ fmt.Fprintf(&sb, `%s`, isbn13)
} else {
- fmt.Fprintf(&buf, `%s`, r.ExtIDs.ISBN[0])
+ fmt.Fprintf(&sb, `%s`, r.ExtIDs.ISBN[0])
}
}
- return buf.String()
+ return sb.String()
}
// ParseIsbn tries to find and validate ISBN from unstructured data. Returns a