]> Sergey Matveev's repositories - tofuproxy.git/commitdiff
Fix various lint warnings and suggestions master
authorSergey Matveev <stargrave@stargrave.org>
Tue, 6 Aug 2024 12:02:21 +0000 (15:02 +0300)
committerSergey Matveev <stargrave@stargrave.org>
Tue, 6 Aug 2024 12:02:24 +0000 (15:02 +0300)
29 files changed:
caches/caches.go
cmd/danechk/main.go
cmd/tofuproxy/main.go
doc/download.texi
doc/index.texi
doc/integrity.texi
doc/why.texi
fifos/add.go
fifos/del.go
fifos/list.go
fifos/log.go
fifos/restricted.go
fifos/spies.go
fifos/tls.go
fifos/warcs.go
go.mod
go.sum
httpauth.go
rounds/gemini.go
rounds/redirectHTML.go
tls/dial.go
tls/tlsauth.go
tls/verify.go
trip.go
warc/compressed.go
warc/gzip.go
warc/reader.go
warc/record.go
warc/uris.go

index 81449349fac68479c2e89db80bbc72013239bc24..3d802d0f4da3f6db309e147287174b648acc24fc 100644 (file)
@@ -21,6 +21,6 @@ var (
        Spies  = make([]string, 0)
        SpiesM sync.RWMutex
 
-       Restricted = make(map[string][]string)
+       Restricted  = make(map[string][]string)
        RestrictedM sync.RWMutex
 )
index b4dda425d7136d475967c420654e5b4a249cb74e..cdf64196f5d550f17e4673a5fa44e5e7ab2aa353 100644 (file)
@@ -21,7 +21,7 @@ import (
        "fmt"
        "log"
 
-       "go.cypherpunks.ru/ucspi"
+       "go.cypherpunks.su/ucspi/v2"
        ttls "go.stargrave.org/tofuproxy/tls"
 )
 
index 625535d527536b627b150da78e65c479c06a5619..8bf62ff26b53b1d09dee7733da5d3d5cbdd620f6 100644 (file)
@@ -22,7 +22,7 @@ import (
        "net"
        "net/http"
 
-       "go.cypherpunks.ru/ucspi"
+       "go.cypherpunks.su/ucspi/v2"
        "go.stargrave.org/tofuproxy"
        "go.stargrave.org/tofuproxy/fifos"
        "go.stargrave.org/tofuproxy/rounds"
index dd5bb5d2643ef8b5302bcd55ab90cc6193c15208..64845135f9d53b393c295628d611384cf6ee80b2 100644 (file)
@@ -1,6 +1,12 @@
 @multitable {XXXXX} {XXXX-XX-XX} {XXXX KiB} {meta4 tar pgp ssh}
 @headitem Version @tab Date @tab Size @tab Tarball
 
+@item 0.6.0 @tab 2024-04-21 @tab 651 KiB @tab
+    @url{download/tofuproxy-0.6.0.tar.zst.meta4, meta4}
+    @url{download/tofuproxy-0.6.0.tar.zst, tar}
+    @url{download/tofuproxy-0.6.0.tar.zst.asc, pgp}
+    @url{download/tofuproxy-0.6.0.tar.zst.sig, ssh}
+
 @item 0.5.0 @tab 2024-04-18 @tab 651 KiB @tab
     @url{download/tofuproxy-0.5.0.tar.zst.meta4, meta4}
     @url{download/tofuproxy-0.5.0.tar.zst, tar}
index de9d845b2851a6e04a2ea900c9a96a3ca8549d48..ad78c5c85e82a58d6e2f81ff7d35bd6cc24e3b8e 100644 (file)
@@ -21,7 +21,7 @@ capabilities:
 @item
 Full TLS connection termination between Web-servers and
 @command{tofuproxy} itself. TLS 1.3, session resumption, GOST
-cryptography (if built with @url{http://www.gostls13.cypherpunks.ru/,
+cryptography (if built with @url{http://www.gostls13.cypherpunks.su/,
 gostls13}) support. Connection between @command{tofuproxy} and browser
 itself uses ephemeral on-the-fly generated certificates with proper
 domain name.
@@ -55,11 +55,10 @@ input dialogue is shown. It automatically loads initial form values from
 @file{.netrc}.
 
 @item
-Permanent HTTP redirects are replaces with non-refreshing HTML page with
+Permanent HTTP redirects are replaced with non-refreshing HTML page with
 the link, to make you explicitly allow that step. Temporary redirects
-are followed if it is neither @url{https://newsboat.org/, Newsboat}
-nor @url{https://www.feeder.stargrave.org/, go.stargrave.org/feeder}
-user-agent, not image paths.
+are followed if it is neither @url{https://www.feeder.stargrave.org/, go.stargrave.org/feeder}
+user-agent, nor image paths.
 
 @item
 JPEG XL, AVIF and WebP images are transparently transcoded to PNG,
index f44863afd124f7420b9d870dad909b2ea2c801d7..84efb55a2fd8911b014400d6b3c4b97d6b71294d 100644 (file)
@@ -27,7 +27,7 @@ $ gpg --auto-key-locate  wkd --locate-keys tofuproxy at stargrave dot org
     Its fingerprint: @code{SHA256:NIDt9iZUizwivY3GoxmGvbQTH7mz/dmV7ZFOXeYfa2o}.
 
 @example
-$ ssh-keygen -Y verify -f PUBKEY-SSH.pub -I tofuproxy@@cypherpunks.ru -n file \
+$ ssh-keygen -Y verify -f PUBKEY-SSH.pub -I tofuproxy@@stargrave.org -n file \
     -s tofuproxy-@value{VERSION}.tar.zst.sig <tofuproxy-@value{VERSION}.tar.zst
 @end example
 
index 7e8aa24bb163a9b2d8527f4400091105eaa5e1ff..0b61ae5133db4582a1e315e1038423d82f974954 100644 (file)
@@ -10,10 +10,7 @@ OpenSSL... All of them sucks, comparing to Go's @code{crypto/tls}.
 @item I am tired that everyone provides very limited certificates trust
 management capabilities, like either certificate or SPKI
 @url{https://en.wikipedia.org/wiki/Certificate_pinning, pinning} with
-@url{https://en.wikipedia.org/wiki/Trust_on_first_use, TOFU}. Even my
-beloved @url{https://en.wikipedia.org/wiki/Xombrero, Xombrero} browser
-still pins only the whole certificate, but its public key would be much
-more sufficient and convenient to work with.
+@url{https://en.wikipedia.org/wiki/Trust_on_first_use, TOFU}.
 
 @item I am tired that many clients provides very few information about
 certificates and connections at all.
@@ -27,8 +24,6 @@ kind of @url{https://en.wikipedia.org/wiki/Privoxy, Privoxy}, but it is
 not friendly with TLS connections, obviously. Or use yet another
 browser-specific plugin.
 
-@item Xombrero sometimes has problems with HTTP-based authorization.
-
 @item Hardly anyone does
 @url{https://en.wikipedia.org/wiki/DNS-based_Authentication_of_Named_Entities, DANE}
 checks.
@@ -37,11 +32,9 @@ checks.
 Why the hell people just do not send PostScript documents instead!?
 
 @item And wonderful @url{http://jpegxl.info/, JPEG XL} image format is
-not supported by most browsers. Even pretty old
-@url{https://developers.google.com/speed/webp, WebP}, that has highest
-compression ratio for lossless screenshots, is not supported everywhere,
-especially on old browsers.
-@url{https://aomediacodec.github.io/av1-avif/, AVIF} could be useful too.
+not supported by all browsers. Even pretty old
+@url{https://developers.google.com/speed/webp, WebP}, is not supported
+everywhere, especially on old browsers.
 
 @item None of web browsers has ability to view web archives
 (@url{https://en.wikipedia.org/wiki/Web_ARChive, WARC}s). And most of
index cf8f3fdc2ff57a9adc3db893b57970dc98d7fa69..bf573d089efc286e923ba0577bb5eaa873c8d5ee 100644 (file)
@@ -23,7 +23,7 @@ import (
 )
 
 func readLinesFromFIFO(p string) []string {
-       fd, err := os.OpenFile(p, os.O_RDONLY, os.FileMode(0666))
+       fd, err := os.OpenFile(p, os.O_RDONLY, os.FileMode(0o666))
        if err != nil {
                log.Fatalln(err)
        }
index a1923023a969f57a9013bcc5d920725c30e36057..d8806585d9f91989e946b06c09836c8edb64a39c 100644 (file)
@@ -25,7 +25,7 @@ import (
 
 func del(l *sync.RWMutex, deleter func(string), p string) {
        for {
-               fd, err := os.OpenFile(p, os.O_RDONLY, os.FileMode(0666))
+               fd, err := os.OpenFile(p, os.O_RDONLY, os.FileMode(0o666))
                if err != nil {
                        log.Fatalln(err)
                }
index f571d04c067c9db36afc0a5ae5f9d2750ba78399..13388f8cba7462bd9d8d625a78a998f18561c42d 100644 (file)
@@ -28,7 +28,7 @@ import (
 
 func list(l *sync.RWMutex, m map[string]string, p string) {
        for {
-               fd, err := os.OpenFile(p, os.O_WRONLY|os.O_APPEND, os.FileMode(0666))
+               fd, err := os.OpenFile(p, os.O_WRONLY|os.O_APPEND, os.FileMode(0o666))
                if err != nil {
                        log.Fatalln(err)
                }
@@ -53,7 +53,7 @@ func listRejected(p string) {
 
 func listHTTPAuth(p string) {
        for {
-               fd, err := os.OpenFile(p, os.O_WRONLY|os.O_APPEND, os.FileMode(0666))
+               fd, err := os.OpenFile(p, os.O_WRONLY|os.O_APPEND, os.FileMode(0o666))
                if err != nil {
                        log.Fatalln(err)
                }
@@ -70,15 +70,16 @@ func listHTTPAuth(p string) {
 
 func listTLSAuth(p string) {
        for {
-               fd, err := os.OpenFile(p, os.O_WRONLY|os.O_APPEND, os.FileMode(0666))
+               fd, err := os.OpenFile(p, os.O_WRONLY|os.O_APPEND, os.FileMode(0o666))
                if err != nil {
                        log.Fatalln(err)
                }
                caches.TLSAuthCacheM.RLock()
+               var cert *x509.Certificate
                for host, tlsCert := range caches.TLSAuthCache {
                        subj := "NONE"
                        if len(tlsCert.Certificate) != 0 {
-                               cert, err := x509.ParseCertificate(tlsCert.Certificate[0])
+                               cert, err = x509.ParseCertificate(tlsCert.Certificate[0])
                                if err != nil {
                                        log.Fatalln(err)
                                }
index 6cdb87d948f47fee0c562ed27265e20750d4be42..e749eb34d731560ce63559e43b135e6973d948e7 100644 (file)
@@ -21,7 +21,7 @@ import (
        "os"
        "time"
 
-       "go.cypherpunks.ru/tai64n/v2"
+       "go.cypherpunks.su/tai64n/v3"
 )
 
 var (
@@ -44,7 +44,7 @@ var (
 func logger(c chan string, p string) {
        tai := new(tai64n.TAI64N)
        for {
-               fd, err := os.OpenFile(p, os.O_WRONLY|os.O_APPEND, os.FileMode(0666))
+               fd, err := os.OpenFile(p, os.O_WRONLY|os.O_APPEND, os.FileMode(0o666))
                if err != nil {
                        log.Fatalln(err)
                }
index 6b8c319537c0d809c9681ee3fdafe7c77849ca4c..de6a7f4e1e4b29ce1e58a3c93504c90ccf37b8e5 100644 (file)
@@ -27,7 +27,7 @@ import (
 
 func listRestricted(p string) {
        for {
-               fd, err := os.OpenFile(p, os.O_WRONLY|os.O_APPEND, os.FileMode(0666))
+               fd, err := os.OpenFile(p, os.O_WRONLY|os.O_APPEND, os.FileMode(0o666))
                if err != nil {
                        log.Fatalln(err)
                }
index d0fa4a9cd73c5befa4e163d96c0816a223fa8b9c..51dc6542b52bc1754bfcc19bb688a90fe8c808db 100644 (file)
@@ -25,7 +25,7 @@ import (
 
 func listSpies(p string) {
        for {
-               fd, err := os.OpenFile(p, os.O_WRONLY|os.O_APPEND, os.FileMode(0666))
+               fd, err := os.OpenFile(p, os.O_WRONLY|os.O_APPEND, os.FileMode(0o666))
                if err != nil {
                        log.Fatalln(err)
                }
index 01a70600e7a4e676f3f8589e59c343848f7669fc..056f28c47a7c2a90c06fb0c04fb3c95701be5c31 100644 (file)
@@ -21,7 +21,7 @@ import (
        "log"
        "strings"
 
-       "go.cypherpunks.ru/ucspi"
+       "go.cypherpunks.su/ucspi/v2"
        "go.stargrave.org/tofuproxy/caches"
 )
 
index 54f86a5b72d6900f513e9da1bf3fe6a7742c8e4c..ba99b9fa2e6fb1dd6fd690906c4f34fbd7629170 100644 (file)
@@ -26,7 +26,7 @@ import (
 
 func listWARCs(p string) {
        for {
-               fd, err := os.OpenFile(p, os.O_WRONLY|os.O_APPEND, os.FileMode(0666))
+               fd, err := os.OpenFile(p, os.O_WRONLY|os.O_APPEND, os.FileMode(0o666))
                if err != nil {
                        log.Fatalln(err)
                }
diff --git a/go.mod b/go.mod
index e1299a03baee94df1ac5a034ea684b815a462634..e53812b483cda6e4723d8abbab924e1afdf1f799 100644 (file)
--- a/go.mod
+++ b/go.mod
@@ -5,9 +5,9 @@ go 1.21
 require (
        github.com/dustin/go-humanize v1.0.1
        github.com/miekg/dns v1.1.57
-       go.cypherpunks.ru/netrc v0.1.0
-       go.cypherpunks.ru/tai64n/v2 v2.0.1
-       go.cypherpunks.ru/ucspi v0.1.0
+       go.cypherpunks.su/netrc/v2 v2.0.0
+       go.cypherpunks.su/tai64n/v3 v3.0.0
+       go.cypherpunks.su/ucspi/v2 v2.0.0
 )
 
 require (
diff --git a/go.sum b/go.sum
index d0930babda48948f5ae08591456047ff7a2181d1..05f2eff01abb4f23a2989fbc1e7b3ad74ef42c22 100644 (file)
--- a/go.sum
+++ b/go.sum
@@ -2,12 +2,14 @@ github.com/dustin/go-humanize v1.0.1 h1:GzkhY7T5VNhEkwH0PVJgjz+fX1rhBrR7pRT3mDkp
 github.com/dustin/go-humanize v1.0.1/go.mod h1:Mu1zIs6XwVuF/gI1OepvI0qD18qycQx+mFykh5fBlto=
 github.com/miekg/dns v1.1.57 h1:Jzi7ApEIzwEPLHWRcafCN9LZSBbqQpxjt/wpgvg7wcM=
 github.com/miekg/dns v1.1.57/go.mod h1:uqRjCRUuEAA6qsOiJvDd+CFo/vW+y5WR6SNmHE55hZk=
-go.cypherpunks.ru/netrc v0.1.0 h1:dzaSh4lgpPXvLzUME/hTSegg+Uw1aPEmC79fxbPLFGk=
-go.cypherpunks.ru/netrc v0.1.0/go.mod h1:ZmQaL9ENEII++WQooelccr33XZcBhKd8VgtcICf4SIE=
-go.cypherpunks.ru/tai64n/v2 v2.0.1 h1:AnwUUgi0EixZcr6nzjUaOy2DFInFwbNRkBkgon4oJfU=
-go.cypherpunks.ru/tai64n/v2 v2.0.1/go.mod h1:Jlva0YVJBpaRFAJ4jfY4BXVPuav0GMyGXzYPSKCCCL0=
-go.cypherpunks.ru/ucspi v0.1.0 h1:1w0E1mSf5oo3ozSSRUZN8Mf4/Ba18S3q7c5CDeCuHZA=
-go.cypherpunks.ru/ucspi v0.1.0/go.mod h1:mrkWllR0o0B/BocrUAL4DhcKLPK6XycObSswHUL5m6s=
+go.cypherpunks.su/netrc/v2 v2.0.0 h1:IWJ0fPcQoccn8VbqzAQf1/4rj8zw0Bf6X5kAkzwEd48=
+go.cypherpunks.su/netrc/v2 v2.0.0/go.mod h1:F5Ea8ii3R9dNUE0ixE61OYIhvJQVLLdIJjrU/3qROjw=
+go.cypherpunks.su/tai64n/v3 v3.0.0 h1:JvQiZJwkswUttMNcPrYS4KUK9Zfl6xllD0N6ZnSZX/U=
+go.cypherpunks.su/tai64n/v3 v3.0.0/go.mod h1:zGDFuyiFKJk+iem8lyBaFeCm+MNMOn7RRWy456n1J78=
+go.cypherpunks.su/ucspi/v2 v2.0.0 h1:Ha/0xfi0nXL/4xdiXqKbHdbXWE/qKcnXux4hG7c/lwM=
+go.cypherpunks.su/ucspi/v2 v2.0.0/go.mod h1:GIIOgXFLLze7hG1sAmXmPNTopVrAaFi5m+GMUA72fXY=
+golang.org/x/crypto v0.16.0 h1:mMMrFzRSCF0GvB7Ne27XVtVAaXLrPmgPC7/v0tkwHaY=
+golang.org/x/crypto v0.16.0/go.mod h1:gCAAfMLgwOJRpTjQ2zCCt2OcSfYMTeZVSRtQlPC7Nq4=
 golang.org/x/mod v0.14.0 h1:dGoOF9QVLYng8IHTm7BAyWqCqSheQ5pYWGhzW00YJr0=
 golang.org/x/mod v0.14.0/go.mod h1:hTbmBsO62+eylJbnUtE2MGJUyE7QWk4xUqPFrRgJ+7c=
 golang.org/x/net v0.19.0 h1:zTwKpTd2XuCqf8huc7Fo2iSy+4RHPd10s4KzeTnVr1c=
index 8e324528306d630edc11ca60723dcf0665db3327..df1cf858f2e639e73ab39d7fd7599db40b49b037 100644 (file)
@@ -23,7 +23,7 @@ import (
        "os/exec"
        "strings"
 
-       "go.cypherpunks.ru/netrc"
+       "go.cypherpunks.su/netrc/v2"
        ttls "go.stargrave.org/tofuproxy/tls"
 )
 
@@ -31,7 +31,6 @@ func authDialog(host, realm string) (string, string, error) {
        var b bytes.Buffer
        userInit, passInit := netrc.Find(host)
        fmt.Fprintf(&b, `
-tk_setPalette grey
 wm title . "Unauthorized: %s"
 
 label .luser -text "User"
index 71da97f361bfe33526a696be30e00ac0b2177b62..2b480ed5a730695dbdd9fe494fd12540dd0a503c 100644 (file)
@@ -195,7 +195,8 @@ func RoundGemini(
                !strings.Contains(req.Header.Get("Accept"), ContentTypeGemini) {
                w.Header().Add("Content-Type", "text/html")
                w.WriteHeader(http.StatusOK)
-               raw, err := io.ReadAll(br)
+               var raw []byte
+               raw, err = io.ReadAll(br)
                if err != nil {
                        log.Printf("%s: can not read response body: %+v\n", req.URL, err)
                        return false, err
index 4f8dec3c437f29de611d7039c1e94067a7efb7ea..93e9d490a2498cf8affcb75010637080e9bad498 100644 (file)
@@ -43,13 +43,7 @@ var imageExts = map[string]struct{}{
 }
 
 func isFeeder(req *http.Request) bool {
-       if strings.Contains(req.Header.Get("User-Agent"), "newsboat/") {
-               return true
-       }
-       if strings.Contains(req.Header.Get("User-Agent"), "stargrave.org-feeder/") {
-               return true
-       }
-       return false
+       return strings.Contains(req.Header.Get("User-Agent"), "stargrave.org-feeder/")
 }
 
 func RoundRedirectHTML(
index aead1c8e70eee70c0467ccae91e487cbe052b7fc..35f43a9ebe152d808b83197bdbadc7253f6c04f3 100644 (file)
@@ -23,7 +23,7 @@ import (
        "fmt"
        "net"
 
-       "go.cypherpunks.ru/ucspi"
+       "go.cypherpunks.su/ucspi/v2"
        "go.stargrave.org/tofuproxy/fifos"
 )
 
index 1a9d95788b7446fb46cf15f4371ba6d0d41e18e5..62763b90c59bb3db646b449e7b2c3ff164f71069 100644 (file)
@@ -29,7 +29,7 @@ import (
        "strconv"
        "strings"
 
-       "go.cypherpunks.ru/ucspi"
+       "go.cypherpunks.su/ucspi/v2"
        "go.stargrave.org/tofuproxy/caches"
        "go.stargrave.org/tofuproxy/fifos"
 )
@@ -56,7 +56,6 @@ func (g *ClientCertificateGetter) get(
        }
        var b bytes.Buffer
        fmt.Fprintf(&b, `
-tk_setPalette grey
 wm title . "TLS client authentication: %s"
 
 set lb [listbox .lb]
@@ -105,11 +104,13 @@ foreach sigScheme {%s} {
        tlsCerts = append(tlsCerts, nil)
        for i, ent := range ents {
                p := filepath.Join(CCerts, ent.Name())
-               _, cert, err := ucspi.CertificateFromFile(p)
+               var cert *x509.Certificate
+               _, cert, err = ucspi.CertificateFromFile(p)
                if err != nil {
                        log.Fatalln(err)
                }
-               prv, err := ucspi.PrivateKeyFromFile(p)
+               var prv any
+               prv, err = ucspi.PrivateKeyFromFile(p)
                if err != nil {
                        log.Fatalln(err)
                }
index 6e45c3eec2a25eae3d849a9f3f7301b37a1bedf3..cbd89be83792de78aba6e56a625bfcc7c7eea603 100644 (file)
@@ -32,7 +32,7 @@ import (
        "strings"
        "sync"
 
-       "go.cypherpunks.ru/ucspi"
+       "go.cypherpunks.su/ucspi/v2"
        "go.stargrave.org/tofuproxy/caches"
        "go.stargrave.org/tofuproxy/fifos"
 )
@@ -65,7 +65,6 @@ proc certsDecode {raws} {
 set certsTheir [certsDecode $certsTheir]
 set certsOur [certsDecode $certsOur]
 
-tk_setPalette grey
 wm title . $host
 
 proc paginator {i delta t l certs} {
diff --git a/trip.go b/trip.go
index 06a6f905c7af6c785aee0359fbe3a9cb375d05e8..0e179a5b00aabdfd70b97d8d956f6ffbfd41a5c4 100644 (file)
--- a/trip.go
+++ b/trip.go
@@ -103,7 +103,8 @@ Retry:
                fifos.LogVarious <- fmt.Sprintf(
                        "%s %s\tHTTP authorization required", req.Method, req.URL.Host,
                )
-               user, pass, err := authDialog(host, resp.Header.Get("WWW-Authenticate"))
+               var user, pass string
+               user, pass, err = authDialog(host, resp.Header.Get("WWW-Authenticate"))
                if err != nil {
                        caches.HTTPAuthCacheM.Unlock()
                        fifos.LogErr <- fmt.Sprintf("%s\t%s", req.URL.Host, err.Error())
@@ -132,20 +133,23 @@ Retry:
                }
        }
 
-       for _, round := range []Round{
-               rounds.RoundDenyFonts,
-               rounds.RoundTranscodeWebP,
-               rounds.RoundTranscodeJXL,
-               rounds.RoundTranscodeAVIF,
-               rounds.RoundRedirectHTML,
-       } {
-               cont, err := round(host, resp, w, req)
-               if err != nil {
-                       http.Error(w, err.Error(), http.StatusBadGateway)
-                       return
-               }
-               if !cont {
-                       return
+       {
+               var cont bool
+               for _, round := range []Round{
+                       rounds.RoundDenyFonts,
+                       rounds.RoundTranscodeWebP,
+                       rounds.RoundTranscodeJXL,
+                       rounds.RoundTranscodeAVIF,
+                       rounds.RoundRedirectHTML,
+               } {
+                       cont, err = round(host, resp, w, req)
+                       if err != nil {
+                               http.Error(w, err.Error(), http.StatusBadGateway)
+                               return
+                       }
+                       if !cont {
+                               return
+                       }
                }
        }
 
index 84b30c35e5c0e4bf91ece7d498eee2f74578698e..c0852270bd7a38f14f3e53061648cb22b1622df8 100644 (file)
@@ -29,12 +29,11 @@ import (
 )
 
 type CompressedReader struct {
-       cmd     *exec.Cmd
-       fd      *os.File
-       stdout  io.ReadCloser
-       offsets []Offset
-
+       stdout    io.ReadCloser
+       cmd       *exec.Cmd
+       fd        *os.File
        offW      *os.File
+       offsets   []Offset
        offReader sync.WaitGroup
 }
 
@@ -79,7 +78,8 @@ func NewCompressedReader(
                cmd.Stdin = io.MultiReader(bytes.NewReader(dict), fd)
        }
        if offsets == nil {
-               offR, offW, err := os.Pipe()
+               var offR, offW *os.File
+               offR, offW, err = os.Pipe()
                if err != nil {
                        fd.Close()
                        return nil, err
index fc20ac451892e463ee7db57e9f22e3fa5f94abef..6a675eed1da4d68a4e04c998c9546e0fe399ae00 100644 (file)
@@ -91,9 +91,9 @@ func NewGZIPReader(
        gr := GZIPReader{r: r}
        go func() {
                z.Multistream(false)
-               var offset, offsetPrev int64
+               var offset, offsetPrev, written int64
                for {
-                       written, err := io.Copy(w, z)
+                       written, err = io.Copy(w, z)
                        if err != nil {
                                w.CloseWithError(err)
                                return
index 50037c734edd89764f494cc8f6410e78bc0487a4..6d0993cf378463e862171c83c877304b03e44b21 100644 (file)
@@ -30,9 +30,9 @@ type Reader struct {
        Path    string
        rrr     RawRecordReader
        br      *bufio.Reader
-       offset  int64
        prevRec *Record
        offsets []Offset
+       offset  int64
 }
 
 func NewReader(warcPath string) (*Reader, error) {
@@ -81,7 +81,8 @@ func (r *Reader) ReadRecord() (*Record, io.Reader, error) {
        hdrLen := len(line)
        hdr := NewHeader()
        for {
-               line, err := r.br.ReadString('\n')
+               var line string
+               line, err = r.br.ReadString('\n')
                if err != nil {
                        return nil, nil, err
                }
index 38181ab92724bc509f05402a87846624a5efe365..de3015185f718af02ce15ee6b8b3166a2e1e1b90 100644 (file)
@@ -22,15 +22,13 @@ import (
 )
 
 type Record struct {
-       WARCPath string
-       Offset   int64
-       Size     int64
-
-       Hdr      Header
-       HdrLen   int
-       HdrLines []string
-
+       WARCPath      string
+       Hdr           Header
+       HdrLines      []string
        Continuations []*Record
+       Offset        int64
+       Size          int64
+       HdrLen        int
 }
 
 func (rec *Record) URI() string {
index 56cd415d1a51868fc3b05e99bbd53403431107dd..37644ac218e9d6c3db02a83be5e943c183c3d371 100644 (file)
@@ -46,10 +46,10 @@ func Add(warcPath string) error {
                var uris map[string]*Record
                var offsets []Offset
                dec := gob.NewDecoder(fd)
-               if err := dec.Decode(&uris); err != nil {
+               if err = dec.Decode(&uris); err != nil {
                        return err
                }
-               if err := dec.Decode(&offsets); err != nil {
+               if err = dec.Decode(&offsets); err != nil {
                        return err
                }
                WARCsM.Lock()
@@ -59,7 +59,7 @@ func Add(warcPath string) error {
                log.Println("loaded marshalled index:", warcPath+IndexExt)
                return nil
        }
-       if err != nil && !errors.Is(err, fs.ErrNotExist) {
+       if !errors.Is(err, fs.ErrNotExist) {
                return err
        }
        r, err := NewReader(warcPath)
@@ -135,7 +135,7 @@ func SaveIndices() error {
                fd, err := os.OpenFile(
                        p+tmpSuffix,
                        os.O_WRONLY|os.O_CREATE|os.O_EXCL,
-                       os.FileMode(0666),
+                       os.FileMode(0o666),
                )
                if err != nil {
                        return err