diff --git a/cmd/stcrashreceiver/main.go b/cmd/stcrashreceiver/main.go index c6a187161..62b70d5c2 100644 --- a/cmd/stcrashreceiver/main.go +++ b/cmd/stcrashreceiver/main.go @@ -90,7 +90,7 @@ func handleFailureFn(dsn, failureDir string) func(w http.ResponseWriter, req *ht for k, v := range r.Extra { pkt.Extra[k] = v } - if len(r.Goroutines) != 0 { + if r.Goroutines != "" { url, err := saveFailureWithGoroutines(r.FailureData, failureDir) if err != nil { log.Println("Saving failure report:", err) diff --git a/cmd/syncthing/main.go b/cmd/syncthing/main.go index 74c6ea84d..7184085d4 100644 --- a/cmd/syncthing/main.go +++ b/cmd/syncthing/main.go @@ -647,7 +647,7 @@ func syncthingMain(options serveOptions) { setupSignalHandling(app) - if len(os.Getenv("GOMAXPROCS")) == 0 { + if os.Getenv("GOMAXPROCS") == "" { runtime.GOMAXPROCS(runtime.NumCPU()) } diff --git a/lib/config/size.go b/lib/config/size.go index 1124d0e38..d4e6761aa 100644 --- a/lib/config/size.go +++ b/lib/config/size.go @@ -16,7 +16,7 @@ import ( func ParseSize(s string) (Size, error) { s = strings.TrimSpace(s) - if len(s) == 0 { + if s == "" { return Size{}, nil } diff --git a/lib/discover/local.go b/lib/discover/local.go index 01e2feb1c..e70e8509c 100644 --- a/lib/discover/local.go +++ b/lib/discover/local.go @@ -64,7 +64,7 @@ func NewLocal(id protocol.DeviceID, addr string, addrList AddressLister, evLogge return nil, err } - if len(host) == 0 { + if host == "" { // A broadcast client c.name = "IPv4 local" bcPort, err := strconv.Atoi(port) diff --git a/lib/fs/util.go b/lib/fs/util.go index 2ffd6cc22..8c810f66a 100644 --- a/lib/fs/util.go +++ b/lib/fs/util.go @@ -55,7 +55,7 @@ func WindowsInvalidFilename(name string) error { // None of the path components should end in space or period, or be a // reserved name. for _, part := range strings.Split(name, `\`) { - if len(part) == 0 { + if part == "" { continue } switch part[len(part)-1] { diff --git a/lib/model/folder_sendrecv.go b/lib/model/folder_sendrecv.go index bc3f45c90..530e8c77c 100644 --- a/lib/model/folder_sendrecv.go +++ b/lib/model/folder_sendrecv.go @@ -737,7 +737,7 @@ func (f *sendReceiveFolder) handleSymlink(file protocol.FileInfo, snap *db.Snaps l.Debugf("need symlink\n\t%v\n\t%v", file, curFile) } - if len(file.SymlinkTarget) == 0 { + if file.SymlinkTarget == "" { // Index entry from a Syncthing predating the support for including // the link target in the index entry. We log this as an error. f.newPullError(file.Name, errIncompatibleSymlink) diff --git a/lib/model/model.go b/lib/model/model.go index d64d01269..124bc3699 100644 --- a/lib/model/model.go +++ b/lib/model/model.go @@ -511,7 +511,7 @@ func (m *model) cleanupFolderLocked(cfg config.FolderConfiguration) { } func (m *model) restartFolder(from, to config.FolderConfiguration, cacheIgnoredFiles bool) error { - if len(to.ID) == 0 { + if to.ID == "" { panic("bug: cannot restart empty folder ID") } if to.ID != from.ID { diff --git a/lib/protocol/encryption.go b/lib/protocol/encryption.go index b6e747b70..c78fe2810 100644 --- a/lib/protocol/encryption.go +++ b/lib/protocol/encryption.go @@ -547,7 +547,7 @@ func slashify(s string) string { // deslashify removes slashes and encrypted file extensions from the string. // This is the inverse of slashify(). func deslashify(s string) (string, error) { - if len(s) == 0 || !strings.HasPrefix(s[1:], encryptedDirExtension) { + if s == "" || !strings.HasPrefix(s[1:], encryptedDirExtension) { return "", fmt.Errorf("invalid encrypted path: %q", s) } s = s[:1] + s[1+len(encryptedDirExtension):] @@ -575,7 +575,7 @@ func IsEncryptedParent(pathComponents []string) bool { } else if l == 0 { return false } - if len(pathComponents[0]) == 0 { + if pathComponents[0] == "" { return false } if pathComponents[0][1:] != encryptedDirExtension { diff --git a/lib/scanner/walk_test.go b/lib/scanner/walk_test.go index 165cd7183..a83664dd6 100644 --- a/lib/scanner/walk_test.go +++ b/lib/scanner/walk_test.go @@ -748,12 +748,12 @@ func TestStopWalk(t *testing.T) { f := res.File t.Log("Scanned", f) if f.IsDirectory() { - if len(f.Name) == 0 || f.Permissions == 0 { + if f.Name == "" || f.Permissions == 0 { t.Error("Bad directory entry", f) } dirs++ } else { - if len(f.Name) == 0 || len(f.Blocks) == 0 || f.Permissions == 0 { + if f.Name == "" || len(f.Blocks) == 0 || f.Permissions == 0 { t.Error("Bad file entry", f) } files++ diff --git a/lib/upnp/upnp.go b/lib/upnp/upnp.go index f88f0f2c7..ea4495cb8 100644 --- a/lib/upnp/upnp.go +++ b/lib/upnp/upnp.go @@ -383,7 +383,7 @@ func getIGDServices(deviceUUID string, localIPAddress net.IP, rootURL string, de l.Debugln(rootURL, "- no services of type", URN, " found on connection.") for _, service := range services { - if len(service.ControlURL) == 0 { + if service.ControlURL == "" { l.Infoln(rootURL+"- malformed", service.Type, "description: no control URL.") } else { u, _ := url.Parse(rootURL) diff --git a/lib/ur/contract/contract.go b/lib/ur/contract/contract.go index 8e8e31e1e..e4bb52ec2 100644 --- a/lib/ur/contract/contract.go +++ b/lib/ur/contract/contract.go @@ -410,7 +410,7 @@ func clear(v interface{}, since int) error { tag := t.Field(i).Tag v := tag.Get("since") - if len(v) == 0 { + if v == "" { f.Set(reflect.Zero(f.Type())) continue }