mirror of
https://github.com/syncthing/syncthing.git
synced 2025-12-23 22:18:14 -05:00
chore: linter: perfsprint
Signed-off-by: Jakob Borg <jakob@kastelo.net>
This commit is contained in:
@@ -10,7 +10,7 @@ import (
|
||||
"bytes"
|
||||
"compress/gzip"
|
||||
"crypto/sha256"
|
||||
"fmt"
|
||||
"encoding/hex"
|
||||
"net"
|
||||
"net/http"
|
||||
"os"
|
||||
@@ -32,7 +32,7 @@ func userIDFor(req *http.Request) string {
|
||||
now := time.Now().Format("200601")
|
||||
salt := "stcrashreporter"
|
||||
hash := sha256.Sum256([]byte(salt + addr + now))
|
||||
return fmt.Sprintf("%x", hash[:8])
|
||||
return hex.EncodeToString(hash[:8])
|
||||
}
|
||||
|
||||
// 01234567890abcdef... => 01/23
|
||||
|
||||
@@ -14,6 +14,7 @@ import (
|
||||
"os"
|
||||
"os/signal"
|
||||
"path/filepath"
|
||||
"strconv"
|
||||
"strings"
|
||||
"sync/atomic"
|
||||
"syscall"
|
||||
@@ -247,10 +248,10 @@ func main() {
|
||||
query.Set("pingInterval", pingInterval.String())
|
||||
query.Set("networkTimeout", networkTimeout.String())
|
||||
if sessionLimitBps > 0 {
|
||||
query.Set("sessionLimitBps", fmt.Sprint(sessionLimitBps))
|
||||
query.Set("sessionLimitBps", strconv.Itoa(sessionLimitBps))
|
||||
}
|
||||
if globalLimitBps > 0 {
|
||||
query.Set("globalLimitBps", fmt.Sprint(globalLimitBps))
|
||||
query.Set("globalLimitBps", strconv.Itoa(globalLimitBps))
|
||||
}
|
||||
if statusAddr != "" {
|
||||
query.Set("statusAddr", statusAddr)
|
||||
|
||||
@@ -472,7 +472,7 @@ func ipv4Identity(port int) string {
|
||||
}
|
||||
|
||||
func ipv6Identity(addr string) string {
|
||||
return fmt.Sprintf("IPv6 local multicast discovery on address %s", addr)
|
||||
return "IPv6 local multicast discovery on address " + addr
|
||||
}
|
||||
|
||||
func http2EnabledTransport(t *http.Transport) *http.Transport {
|
||||
|
||||
@@ -12,6 +12,7 @@ import (
|
||||
"context"
|
||||
"fmt"
|
||||
"net/http"
|
||||
"strconv"
|
||||
"strings"
|
||||
"sync"
|
||||
"time"
|
||||
@@ -50,13 +51,13 @@ func (resp *recordedResponse) ServeHTTP(w http.ResponseWriter, r *http.Request)
|
||||
|
||||
if strings.Contains(r.Header.Get("Accept-Encoding"), "gzip") {
|
||||
w.Header().Set("Content-Encoding", "gzip")
|
||||
w.Header().Set("Content-Length", fmt.Sprint(len(resp.gzip)))
|
||||
w.Header().Set("Content-Length", strconv.Itoa(len(resp.gzip)))
|
||||
w.WriteHeader(resp.status)
|
||||
_, _ = w.Write(resp.gzip)
|
||||
return
|
||||
}
|
||||
|
||||
w.Header().Set("Content-Length", fmt.Sprint(len(resp.data)))
|
||||
w.Header().Set("Content-Length", strconv.Itoa(len(resp.data)))
|
||||
w.WriteHeader(resp.status)
|
||||
_, _ = w.Write(resp.data)
|
||||
}
|
||||
|
||||
@@ -10,6 +10,7 @@ import (
|
||||
"bufio"
|
||||
"bytes"
|
||||
"crypto/sha256"
|
||||
"encoding/hex"
|
||||
"errors"
|
||||
"fmt"
|
||||
"io"
|
||||
@@ -353,7 +354,7 @@ func hashPatterns(patterns []Pattern) string {
|
||||
h.Write([]byte(pat.String()))
|
||||
h.Write([]byte("\n"))
|
||||
}
|
||||
return fmt.Sprintf("%x", h.Sum(nil))
|
||||
return hex.EncodeToString(h.Sum(nil))
|
||||
}
|
||||
|
||||
func loadIgnoreFile(fs fs.Filesystem, file string) (fs.File, fs.FileInfo, error) {
|
||||
|
||||
@@ -7,7 +7,6 @@
|
||||
package osutil
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"path/filepath"
|
||||
|
||||
"github.com/syncthing/syncthing/lib/fs"
|
||||
@@ -19,7 +18,7 @@ type TraversesSymlinkError struct {
|
||||
}
|
||||
|
||||
func (e *TraversesSymlinkError) Error() string {
|
||||
return fmt.Sprintf("traverses symlink: %s", e.path)
|
||||
return "traverses symlink: " + e.path
|
||||
}
|
||||
|
||||
// NotADirectoryError is an error indicating an expected path is not a directory
|
||||
@@ -28,7 +27,7 @@ type NotADirectoryError struct {
|
||||
}
|
||||
|
||||
func (e *NotADirectoryError) Error() string {
|
||||
return fmt.Sprintf("not a directory: %s", e.path)
|
||||
return "not a directory: " + e.path
|
||||
}
|
||||
|
||||
// TraversesSymlink returns an error if any path component of name (including name
|
||||
|
||||
@@ -9,7 +9,6 @@ package pmp
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"fmt"
|
||||
"log/slog"
|
||||
"net"
|
||||
"strings"
|
||||
@@ -90,7 +89,7 @@ type wrapper struct {
|
||||
}
|
||||
|
||||
func (w *wrapper) ID() string {
|
||||
return fmt.Sprintf("NAT-PMP@%s", w.gatewayIP.String())
|
||||
return "NAT-PMP@" + w.gatewayIP.String()
|
||||
}
|
||||
|
||||
func (w *wrapper) GetLocalIPv4Address() net.IP {
|
||||
|
||||
@@ -14,9 +14,9 @@ import (
|
||||
"crypto/sha256"
|
||||
"crypto/x509"
|
||||
"encoding/asn1"
|
||||
"encoding/hex"
|
||||
"encoding/pem"
|
||||
"errors"
|
||||
"fmt"
|
||||
"io"
|
||||
"math/big"
|
||||
|
||||
@@ -135,7 +135,7 @@ func hashReader(r io.Reader) ([]byte, error) {
|
||||
if _, err := io.Copy(h, r); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
hash := []byte(fmt.Sprintf("%x", h.Sum(nil)))
|
||||
hash := []byte(hex.EncodeToString(h.Sum(nil)))
|
||||
return hash, nil
|
||||
}
|
||||
|
||||
|
||||
@@ -86,7 +86,7 @@ type UnsupportedDeviceTypeError struct {
|
||||
}
|
||||
|
||||
func (e *UnsupportedDeviceTypeError) Error() string {
|
||||
return fmt.Sprintf("Unsupported UPnP device of type %s", e.deviceType)
|
||||
return "unsupported UPnP device of type " + e.deviceType
|
||||
}
|
||||
|
||||
const (
|
||||
|
||||
Reference in New Issue
Block a user