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