From b571f780dcc4baafa659bebbc316204a46e42f4f Mon Sep 17 00:00:00 2001 From: Nick White Date: Fri, 23 Jul 2021 16:17:40 +0100 Subject: gofmt --- cmd/analysestats/main.go | 6 +++--- cmd/dehyphenate/main.go | 4 ++-- cmd/dlgbook/main.go | 4 ++-- cmd/eeboxmltohocr/main.go | 6 +++--- cmd/iiifdownloader/main.go | 10 +++++----- 5 files changed, 15 insertions(+), 15 deletions(-) (limited to 'cmd') diff --git a/cmd/analysestats/main.go b/cmd/analysestats/main.go index 10be46a..aeb51ca 100644 --- a/cmd/analysestats/main.go +++ b/cmd/analysestats/main.go @@ -18,8 +18,8 @@ import ( "math" "os" "path/filepath" - "strings" "strconv" + "strings" ) const usage = `Usage: analysestats statsdir csvfile @@ -127,7 +127,7 @@ func getMeanStddevOfBest(bestfn string, conffn string) (float64, float64, error) for _, v := range bestConfs { a += (float64(v) - mean) * (float64(v) - mean) } - variance := a / float64(len(bestConfs) - 1) + variance := a / float64(len(bestConfs)-1) stddev = math.Sqrt(variance) } @@ -153,7 +153,7 @@ func walker(bookstats *Bookstats) filepath.WalkFunc { if len(parts) < 2 || len(b) < 6 { return nil } - prefix := b[0:len(b)-6] // 6 is length of '-hocr' + 1 + prefix := b[0 : len(b)-6] // 6 is length of '-hocr' + 1 ext := parts[len(parts)-1] if ext != "hocr" && ext != "best" { diff --git a/cmd/dehyphenate/main.go b/cmd/dehyphenate/main.go index 0974368..284fc1a 100644 --- a/cmd/dehyphenate/main.go +++ b/cmd/dehyphenate/main.go @@ -34,7 +34,7 @@ func dehyphenateString(in string) string { words := strings.Split(line, " ") last := words[len(words)-1] // the - 2 here is to account for a trailing newline and counting from zero - if len(last) > 0 && last[len(last) - 1] == '-' && i < len(lines) - 2 { + if len(last) > 0 && last[len(last)-1] == '-' && i < len(lines)-2 { nextwords := strings.Split(lines[i+1], " ") if len(nextwords) > 0 { line = line[0:len(line)-1] + nextwords[0] @@ -80,7 +80,7 @@ func main() { for i, l := range h.Lines { w := l.Words[len(l.Words)-1] if len(w.Chars) == 0 { - if len(w.Text) > 0 && w.Text[len(w.Text) - 1] == '-' { + if len(w.Text) > 0 && w.Text[len(w.Text)-1] == '-' { h.Lines[i].Words[len(l.Words)-1].Text = w.Text[0:len(w.Text)-1] + h.Lines[i+1].Words[0].Text h.Lines[i+1].Words[0].Text = "" } diff --git a/cmd/dlgbook/main.go b/cmd/dlgbook/main.go index 65ac870..6518006 100644 --- a/cmd/dlgbook/main.go +++ b/cmd/dlgbook/main.go @@ -78,8 +78,8 @@ func getMetadata(id string) (string, string, string, error) { // designed to be unmarshalled by encoding/json's Unmarshal() type bookInfo struct { VolumeInfo struct { - Title string - Authors []string + Title string + Authors []string PublishedDate string } } diff --git a/cmd/eeboxmltohocr/main.go b/cmd/eeboxmltohocr/main.go index 25c4204..5114678 100644 --- a/cmd/eeboxmltohocr/main.go +++ b/cmd/eeboxmltohocr/main.go @@ -51,7 +51,7 @@ func addPage(pgs *[]Page, number int, text string) { if added == 0 { newpg := Page{number, text} *pgs = append(*pgs, newpg) - } + } } func main() { @@ -100,14 +100,14 @@ func main() { } for _, pg := range pgs { - fn := fmt.Sprintf("%s-%03d.hocr", flag.Arg(1), pg.number - 1) + fn := fmt.Sprintf("%s-%03d.hocr", flag.Arg(1), pg.number-1) f, err := os.Create(fn) if err != nil { log.Fatalf("Could not create file %s: %v\n", fn, err) } defer f.Close() - _, err = io.WriteString(f, hocrHeader + pg.text + hocrFooter) + _, err = io.WriteString(f, hocrHeader+pg.text+hocrFooter) if err != nil { log.Fatalf("Could not write file %s: %v\n", fn, err) } diff --git a/cmd/iiifdownloader/main.go b/cmd/iiifdownloader/main.go index cbb0d5c..6ae2f52 100644 --- a/cmd/iiifdownloader/main.go +++ b/cmd/iiifdownloader/main.go @@ -82,7 +82,7 @@ func parseMets(u string, c *http.Client) ([]string, error) { // designed to be unmarshalled by encoding/xml's Unmarshal() type metsXML struct { FileGrps []struct { - Attr string `xml:"USE,attr"` + Attr string `xml:"USE,attr"` Files []struct { Url string `xml:"href,attr"` } `xml:"file>FLocat"` @@ -168,8 +168,8 @@ func parseIIIFManifest(u string, c *http.Client) ([]string, error) { // redirects to a info.json unless we manually add the appropriate // iiif parameters. if strings.HasPrefix(u, "https://iiif.bodleian.ox.ac.uk") && - !strings.HasSuffix(u, ".jpg") && !strings.HasSuffix(u, ".jpeg") && - !strings.HasSuffix(u, ".png") { + !strings.HasSuffix(u, ".jpg") && !strings.HasSuffix(u, ".jpeg") && + !strings.HasSuffix(u, ".png") { u += "/full/full/0/native.jpg" } urls = append(urls, u) @@ -192,7 +192,7 @@ func urlToPgName(u string) string { } if b != "default.jpg" && b != "native.jpg" && - b != "default.png" && b != "native.png" { + b != "default.png" && b != "native.png" { if path.Ext(b) == "" { return b + ext } @@ -203,7 +203,7 @@ func urlToPgName(u string) string { if len(f) < 5 { return safe } - name := f[len(f) - 5] + name := f[len(f)-5] f2 := strings.Split(name, "_") var numpart, pgnum string -- cgit v1.2.1-24-ge1ad