diff --git a/cmd/stcrashreceiver/stcrashreceiver.go b/cmd/stcrashreceiver/stcrashreceiver.go index f6f988f3e..57b98a5d1 100644 --- a/cmd/stcrashreceiver/stcrashreceiver.go +++ b/cmd/stcrashreceiver/stcrashreceiver.go @@ -59,7 +59,7 @@ func (r *crashReceiver) ServeHTTP(w http.ResponseWriter, req *http.Request) { } // serveGet responds to GET requests by serving the uncompressed report. -func (r *crashReceiver) serveGet(fullPath string, w http.ResponseWriter, _ *http.Request) { +func (*crashReceiver) serveGet(fullPath string, w http.ResponseWriter, _ *http.Request) { fd, err := os.Open(fullPath) if err != nil { http.Error(w, "Not found", http.StatusNotFound) @@ -77,7 +77,7 @@ func (r *crashReceiver) serveGet(fullPath string, w http.ResponseWriter, _ *http // serveHead responds to HEAD requests by checking if the named report // already exists in the system. -func (r *crashReceiver) serveHead(fullPath string, w http.ResponseWriter, _ *http.Request) { +func (*crashReceiver) serveHead(fullPath string, w http.ResponseWriter, _ *http.Request) { if _, err := os.Lstat(fullPath); err != nil { http.Error(w, "Not found", http.StatusNotFound) } @@ -136,6 +136,6 @@ func (r *crashReceiver) servePut(reportID, fullPath string, w http.ResponseWrite } // 01234567890abcdef... => 01/23 -func (r *crashReceiver) dirFor(base string) string { +func (*crashReceiver) dirFor(base string) string { return filepath.Join(base[0:2], base[2:4]) } diff --git a/lib/config/commit_test.go b/lib/config/commit_test.go index ac229e68e..c2a433f50 100644 --- a/lib/config/commit_test.go +++ b/lib/config/commit_test.go @@ -34,7 +34,7 @@ type validationError struct{} func (validationError) VerifyConfiguration(_, _ Configuration) error { return errors.New("some error") } -func (c validationError) CommitConfiguration(_, _ Configuration) bool { +func (validationError) CommitConfiguration(_, _ Configuration) bool { return true } func (validationError) String() string { diff --git a/lib/config/guiconfiguration.go b/lib/config/guiconfiguration.go index 147ed9fdc..cbedfffcb 100644 --- a/lib/config/guiconfiguration.go +++ b/lib/config/guiconfiguration.go @@ -21,7 +21,7 @@ func (c GUIConfiguration) IsAuthEnabled() bool { return c.AuthMode == AuthModeLDAP || (len(c.User) > 0 && len(c.Password) > 0) } -func (c GUIConfiguration) IsOverridden() bool { +func (GUIConfiguration) IsOverridden() bool { return os.Getenv("STGUIADDRESS") != "" } diff --git a/lib/connections/limiter.go b/lib/connections/limiter.go index 66331c221..3f3e84bd7 100644 --- a/lib/connections/limiter.go +++ b/lib/connections/limiter.go @@ -173,7 +173,7 @@ func (lim *limiter) CommitConfiguration(from, to config.Configuration) bool { return true } -func (lim *limiter) String() string { +func (*limiter) String() string { // required by config.Committer interface return "connections.limiter" } diff --git a/lib/connections/service.go b/lib/connections/service.go index 3a5ee82eb..9b9a44574 100644 --- a/lib/connections/service.go +++ b/lib/connections/service.go @@ -492,7 +492,7 @@ func (s *service) connect(ctx context.Context) error { } } -func (s *service) bestDialerPriority(cfg config.Configuration) int { +func (*service) bestDialerPriority(cfg config.Configuration) int { bestDialerPriority := worstDialerPriority for _, df := range dialers { if df.Valid(cfg) != nil { diff --git a/lib/db/keyer.go b/lib/db/keyer.go index fac2d1af3..6a9e1165f 100644 --- a/lib/db/keyer.go +++ b/lib/db/keyer.go @@ -166,7 +166,7 @@ func (k defaultKeyer) GenerateDeviceFileKey(key, folder, device, name []byte) (d return key, nil } -func (k defaultKeyer) NameFromDeviceFileKey(key []byte) []byte { +func (defaultKeyer) NameFromDeviceFileKey(key []byte) []byte { return key[keyPrefixLen+keyFolderLen+keyDeviceLen:] } @@ -196,7 +196,7 @@ func (k defaultKeyer) GenerateGlobalVersionKey(key, folder, name []byte) (global return key, nil } -func (k defaultKeyer) NameFromGlobalVersionKey(key []byte) []byte { +func (defaultKeyer) NameFromGlobalVersionKey(key []byte) []byte { return key[keyPrefixLen+keyFolderLen:] } @@ -215,7 +215,7 @@ func (k defaultKeyer) GenerateBlockMapKey(key, folder, hash, name []byte) (block return key, nil } -func (k defaultKeyer) NameFromBlockMapKey(key []byte) []byte { +func (defaultKeyer) NameFromBlockMapKey(key []byte) []byte { return key[keyPrefixLen+keyFolderLen+keyHashLen:] } @@ -238,7 +238,7 @@ func (k defaultKeyer) GenerateBlockListMapKey(key, folder, hash, name []byte) (b return key, nil } -func (k defaultKeyer) NameFromBlockListMapKey(key []byte) []byte { +func (defaultKeyer) NameFromBlockListMapKey(key []byte) []byte { return key[keyPrefixLen+keyFolderLen+keyHashLen:] } @@ -282,7 +282,7 @@ func (k defaultKeyer) GenerateSequenceKey(key, folder []byte, seq int64) (sequen return key, nil } -func (k defaultKeyer) SequenceFromSequenceKey(key []byte) int64 { +func (defaultKeyer) SequenceFromSequenceKey(key []byte) int64 { return int64(binary.BigEndian.Uint64(key[keyPrefixLen+keyFolderLen:])) } @@ -336,7 +336,7 @@ func (k defaultKeyer) GenerateFolderMetaKey(key, folder []byte) (folderMetaKey, type blockListKey []byte -func (k defaultKeyer) GenerateBlockListKey(key []byte, hash []byte) blockListKey { +func (defaultKeyer) GenerateBlockListKey(key []byte, hash []byte) blockListKey { key = resize(key, keyPrefixLen+len(hash)) key[0] = KeyTypeBlockList copy(key[keyPrefixLen:], hash) @@ -349,7 +349,7 @@ func (k blockListKey) Hash() []byte { type versionKey []byte -func (k defaultKeyer) GenerateVersionKey(key []byte, hash []byte) versionKey { +func (defaultKeyer) GenerateVersionKey(key []byte, hash []byte) versionKey { key = resize(key, keyPrefixLen+len(hash)) key[0] = KeyTypeVersion copy(key[keyPrefixLen:], hash) @@ -374,7 +374,7 @@ func (k defaultKeyer) GeneratePendingFolderKey(key, device, folder []byte) (pend return key, nil } -func (k defaultKeyer) FolderFromPendingFolderKey(key []byte) []byte { +func (defaultKeyer) FolderFromPendingFolderKey(key []byte) []byte { return key[keyPrefixLen+keyDeviceLen:] } @@ -384,14 +384,14 @@ func (k defaultKeyer) DeviceFromPendingFolderKey(key []byte) ([]byte, bool) { type pendingDeviceKey []byte -func (k defaultKeyer) GeneratePendingDeviceKey(key, device []byte) pendingDeviceKey { +func (defaultKeyer) GeneratePendingDeviceKey(key, device []byte) pendingDeviceKey { key = resize(key, keyPrefixLen+len(device)) key[0] = KeyTypePendingDevice copy(key[keyPrefixLen:], device) return key } -func (k defaultKeyer) DeviceFromPendingDeviceKey(key []byte) []byte { +func (defaultKeyer) DeviceFromPendingDeviceKey(key []byte) []byte { return key[keyPrefixLen:] } diff --git a/lib/discover/global.go b/lib/discover/global.go index fade8bc54..bebd3edd0 100644 --- a/lib/discover/global.go +++ b/lib/discover/global.go @@ -301,7 +301,7 @@ func (c *globalClient) sendAnnouncement(ctx context.Context, timer *time.Timer) timer.Reset(defaultReannounceInterval) } -func (c *globalClient) Cache() map[protocol.DeviceID]CacheEntry { +func (*globalClient) Cache() map[protocol.DeviceID]CacheEntry { // The globalClient doesn't do caching return nil } diff --git a/lib/events/events.go b/lib/events/events.go index eec58ee7f..d10c397f4 100644 --- a/lib/events/events.go +++ b/lib/events/events.go @@ -569,7 +569,7 @@ func (*noopSubscription) Poll(_ time.Duration) (Event, error) { return Event{}, errNoop } -func (s *noopSubscription) Mask() EventType { +func (*noopSubscription) Mask() EventType { return 0 } diff --git a/lib/fs/basicfs.go b/lib/fs/basicfs.go index 9aeb10619..11157848d 100644 --- a/lib/fs/basicfs.go +++ b/lib/fs/basicfs.go @@ -27,7 +27,7 @@ var ( type OptionJunctionsAsDirs struct{} -func (o *OptionJunctionsAsDirs) apply(fs Filesystem) Filesystem { +func (*OptionJunctionsAsDirs) apply(fs Filesystem) Filesystem { if basic, ok := fs.(*BasicFilesystem); !ok { l.Warnln("WithJunctionsAsDirs must only be used with FilesystemTypeBasic") } else { @@ -36,7 +36,7 @@ func (o *OptionJunctionsAsDirs) apply(fs Filesystem) Filesystem { return fs } -func (o *OptionJunctionsAsDirs) String() string { +func (*OptionJunctionsAsDirs) String() string { return "junctionsAsDirs" } @@ -265,7 +265,7 @@ func (f *BasicFilesystem) Create(name string) (File, error) { return basicFile{fd, name}, err } -func (f *BasicFilesystem) Walk(_ string, _ WalkFunc) error { +func (*BasicFilesystem) Walk(_ string, _ WalkFunc) error { // implemented in WalkFilesystem return errors.New("not implemented") } @@ -298,7 +298,7 @@ func (f *BasicFilesystem) Usage(name string) (Usage, error) { }, nil } -func (f *BasicFilesystem) Type() FilesystemType { +func (*BasicFilesystem) Type() FilesystemType { return FilesystemTypeBasic } @@ -310,7 +310,7 @@ func (f *BasicFilesystem) Options() []Option { return f.options } -func (f *BasicFilesystem) SameFile(fi1, fi2 FileInfo) bool { +func (*BasicFilesystem) SameFile(fi1, fi2 FileInfo) bool { // Like os.SameFile, we always return false unless fi1 and fi2 were created // by this package's Stat/Lstat method. f1, ok1 := fi1.(basicFileInfo) @@ -322,11 +322,11 @@ func (f *BasicFilesystem) SameFile(fi1, fi2 FileInfo) bool { return os.SameFile(f1.osFileInfo(), f2.osFileInfo()) } -func (f *BasicFilesystem) underlying() (Filesystem, bool) { +func (*BasicFilesystem) underlying() (Filesystem, bool) { return nil, false } -func (f *BasicFilesystem) wrapperType() filesystemWrapperType { +func (*BasicFilesystem) wrapperType() filesystemWrapperType { return filesystemWrapperTypeNone } diff --git a/lib/fs/basicfs_unix.go b/lib/fs/basicfs_unix.go index 9f7f65831..a839c7ea0 100644 --- a/lib/fs/basicfs_unix.go +++ b/lib/fs/basicfs_unix.go @@ -36,7 +36,7 @@ func (f *BasicFilesystem) ReadSymlink(name string) (string, error) { return os.Readlink(name) } -func (f *BasicFilesystem) mkdirAll(path string, perm os.FileMode) error { +func (*BasicFilesystem) mkdirAll(path string, perm os.FileMode) error { return os.MkdirAll(path, perm) } @@ -54,7 +54,7 @@ func (f *BasicFilesystem) Hide(name string) error { return err } -func (f *BasicFilesystem) Roots() ([]string, error) { +func (*BasicFilesystem) Roots() ([]string, error) { return []string{"/"}, nil } diff --git a/lib/fs/basicfs_watch.go b/lib/fs/basicfs_watch.go index 583b45995..d26f83ed0 100644 --- a/lib/fs/basicfs_watch.go +++ b/lib/fs/basicfs_watch.go @@ -113,7 +113,7 @@ func (f *BasicFilesystem) watchLoop(ctx context.Context, name string, roots []st } } -func (f *BasicFilesystem) eventType(notifyType notify.Event) EventType { +func (*BasicFilesystem) eventType(notifyType notify.Event) EventType { if notifyType&rmEventMask != 0 { return Remove } diff --git a/lib/fs/basicfs_watch_test.go b/lib/fs/basicfs_watch_test.go index cfb6c3bba..626aadf22 100644 --- a/lib/fs/basicfs_watch_test.go +++ b/lib/fs/basicfs_watch_test.go @@ -627,10 +627,10 @@ func (e fakeEventInfo) Path() string { return string(e) } -func (e fakeEventInfo) Event() notify.Event { +func (fakeEventInfo) Event() notify.Event { return notify.Write } -func (e fakeEventInfo) Sys() interface{} { +func (fakeEventInfo) Sys() interface{} { return nil } diff --git a/lib/fs/casefs.go b/lib/fs/casefs.go index 929aad120..7468d3191 100644 --- a/lib/fs/casefs.go +++ b/lib/fs/casefs.go @@ -131,11 +131,11 @@ var globalCaseFilesystemRegistry = caseFilesystemRegistry{fss: make(map[fskey]*c // used if the filesystem is known to already behave case-sensitively. type OptionDetectCaseConflicts struct{} -func (o *OptionDetectCaseConflicts) apply(fs Filesystem) Filesystem { +func (*OptionDetectCaseConflicts) apply(fs Filesystem) Filesystem { return globalCaseFilesystemRegistry.get(fs) } -func (o *OptionDetectCaseConflicts) String() string { +func (*OptionDetectCaseConflicts) String() string { return "detectCaseConflicts" } @@ -350,7 +350,7 @@ func (f *caseFilesystem) underlying() (Filesystem, bool) { return f.Filesystem, true } -func (f *caseFilesystem) wrapperType() filesystemWrapperType { +func (*caseFilesystem) wrapperType() filesystemWrapperType { return filesystemWrapperTypeCase } diff --git a/lib/fs/errorfs.go b/lib/fs/errorfs.go index 853e3f48b..903a6696e 100644 --- a/lib/fs/errorfs.go +++ b/lib/fs/errorfs.go @@ -37,7 +37,7 @@ func (fs *errorFilesystem) Remove(_ string) error { retur func (fs *errorFilesystem) RemoveAll(_ string) error { return fs.err } func (fs *errorFilesystem) Rename(_, _ string) error { return fs.err } func (fs *errorFilesystem) Stat(_ string) (FileInfo, error) { return nil, fs.err } -func (fs *errorFilesystem) SymlinksSupported() bool { return false } +func (*errorFilesystem) SymlinksSupported() bool { return false } func (fs *errorFilesystem) Walk(_ string, _ WalkFunc) error { return fs.err } func (fs *errorFilesystem) Unhide(_ string) error { return fs.err } func (fs *errorFilesystem) Hide(_ string) error { return fs.err } @@ -47,10 +47,10 @@ func (fs *errorFilesystem) Roots() ([]string, error) { retur func (fs *errorFilesystem) Usage(_ string) (Usage, error) { return Usage{}, fs.err } func (fs *errorFilesystem) Type() FilesystemType { return fs.fsType } func (fs *errorFilesystem) URI() string { return fs.uri } -func (fs *errorFilesystem) Options() []Option { +func (*errorFilesystem) Options() []Option { return nil } -func (fs *errorFilesystem) SameFile(_, _ FileInfo) bool { return false } +func (*errorFilesystem) SameFile(_, _ FileInfo) bool { return false } func (fs *errorFilesystem) Watch(_ string, _ Matcher, _ context.Context, _ bool) (<-chan Event, <-chan error, error) { return nil, nil, fs.err } @@ -58,10 +58,10 @@ func (fs *errorFilesystem) PlatformData(_ string) (protocol.PlatformData, error) return protocol.PlatformData{}, fs.err } -func (fs *errorFilesystem) underlying() (Filesystem, bool) { +func (*errorFilesystem) underlying() (Filesystem, bool) { return nil, false } -func (fs *errorFilesystem) wrapperType() filesystemWrapperType { +func (*errorFilesystem) wrapperType() filesystemWrapperType { return filesystemWrapperTypeError } diff --git a/lib/fs/fakefs.go b/lib/fs/fakefs.go index 0f542830e..c6c285bf6 100644 --- a/lib/fs/fakefs.go +++ b/lib/fs/fakefs.go @@ -597,23 +597,23 @@ func (fs *fakeFS) Stat(name string) (FileInfo, error) { return fs.Lstat(name) } -func (fs *fakeFS) SymlinksSupported() bool { +func (*fakeFS) SymlinksSupported() bool { return false } -func (fs *fakeFS) Walk(_ string, _ WalkFunc) error { +func (*fakeFS) Walk(_ string, _ WalkFunc) error { return errors.New("not implemented") } -func (fs *fakeFS) Watch(_ string, _ Matcher, _ context.Context, _ bool) (<-chan Event, <-chan error, error) { +func (*fakeFS) Watch(_ string, _ Matcher, _ context.Context, _ bool) (<-chan Event, <-chan error, error) { return nil, nil, ErrWatchNotSupported } -func (fs *fakeFS) Hide(_ string) error { +func (*fakeFS) Hide(_ string) error { return nil } -func (fs *fakeFS) Unhide(_ string) error { +func (*fakeFS) Unhide(_ string) error { return nil } @@ -622,15 +622,15 @@ func (fs *fakeFS) Glob(_ string) ([]string, error) { return nil, errors.New("not implemented") } -func (fs *fakeFS) Roots() ([]string, error) { +func (*fakeFS) Roots() ([]string, error) { return []string{"/"}, nil } -func (fs *fakeFS) Usage(_ string) (Usage, error) { +func (*fakeFS) Usage(_ string) (Usage, error) { return Usage{}, errors.New("not implemented") } -func (fs *fakeFS) Type() FilesystemType { +func (*fakeFS) Type() FilesystemType { return FilesystemTypeFake } @@ -638,7 +638,7 @@ func (fs *fakeFS) URI() string { return fs.uri } -func (fs *fakeFS) Options() []Option { +func (*fakeFS) Options() []Option { return nil } @@ -661,11 +661,11 @@ func (fs *fakeFS) PlatformData(name string) (protocol.PlatformData, error) { return unixPlatformData(fs, name) } -func (fs *fakeFS) underlying() (Filesystem, bool) { +func (*fakeFS) underlying() (Filesystem, bool) { return nil, false } -func (fs *fakeFS) wrapperType() filesystemWrapperType { +func (*fakeFS) wrapperType() filesystemWrapperType { return filesystemWrapperTypeNone } @@ -698,7 +698,7 @@ type fakeFile struct { presentedName string // present (i.e. != "") on insensitive fs only } -func (f *fakeFile) Close() error { +func (*fakeFile) Close() error { return nil } @@ -912,7 +912,7 @@ func (f *fakeFile) Stat() (FileInfo, error) { return info, nil } -func (f *fakeFile) Sync() error { +func (*fakeFile) Sync() error { return nil } diff --git a/lib/fs/logfs.go b/lib/fs/logfs.go index a3fe1a0ac..38b95e0f6 100644 --- a/lib/fs/logfs.go +++ b/lib/fs/logfs.go @@ -168,6 +168,6 @@ func (fs *logFilesystem) underlying() (Filesystem, bool) { return fs.Filesystem, true } -func (fs *logFilesystem) wrapperType() filesystemWrapperType { +func (*logFilesystem) wrapperType() filesystemWrapperType { return filesystemWrapperTypeLog } diff --git a/lib/fs/mtimefs.go b/lib/fs/mtimefs.go index 2dfcbfe6b..404038efb 100644 --- a/lib/fs/mtimefs.go +++ b/lib/fs/mtimefs.go @@ -146,7 +146,7 @@ func (f *mtimeFS) underlying() (Filesystem, bool) { return f.Filesystem, true } -func (f *mtimeFS) wrapperType() filesystemWrapperType { +func (*mtimeFS) wrapperType() filesystemWrapperType { return filesystemWrapperTypeMtime } diff --git a/lib/fs/walkfs.go b/lib/fs/walkfs.go index 176209f17..11d0203d6 100644 --- a/lib/fs/walkfs.go +++ b/lib/fs/walkfs.go @@ -154,6 +154,6 @@ func (f *walkFilesystem) underlying() (Filesystem, bool) { return f.Filesystem, true } -func (f *walkFilesystem) wrapperType() filesystemWrapperType { +func (*walkFilesystem) wrapperType() filesystemWrapperType { return filesystemWrapperTypeWalk } diff --git a/lib/model/folder.go b/lib/model/folder.go index 41d26a4dc..428808170 100644 --- a/lib/model/folder.go +++ b/lib/model/folder.go @@ -237,11 +237,11 @@ func (f *folder) Serve(ctx context.Context) error { } } -func (f *folder) BringToFront(string) {} +func (*folder) BringToFront(string) {} -func (f *folder) Override() {} +func (*folder) Override() {} -func (f *folder) Revert() {} +func (*folder) Revert() {} func (f *folder) DelayScan(next time.Duration) { select { @@ -275,7 +275,7 @@ func (f *folder) SchedulePull() { } } -func (f *folder) Jobs(_, _ int) ([]string, []string, int) { +func (*folder) Jobs(_, _ int) ([]string, []string, int) { return nil, nil, 0 } diff --git a/lib/model/folder_sendonly.go b/lib/model/folder_sendonly.go index 7ab6c6dad..f71cb5de4 100644 --- a/lib/model/folder_sendonly.go +++ b/lib/model/folder_sendonly.go @@ -32,7 +32,7 @@ func newSendOnlyFolder(model *model, fset *db.FileSet, ignores *ignore.Matcher, return f } -func (f *sendOnlyFolder) PullErrors() []FileError { +func (*sendOnlyFolder) PullErrors() []FileError { return nil } diff --git a/lib/model/folder_sendrecv.go b/lib/model/folder_sendrecv.go index 530e8c77c..838d812e8 100644 --- a/lib/model/folder_sendrecv.go +++ b/lib/model/folder_sendrecv.go @@ -1462,7 +1462,7 @@ func (f *sendReceiveFolder) initWeakHashFinder(state copyBlocksState) (*weakhash return weakHashFinder, file } -func (f *sendReceiveFolder) verifyBuffer(buf []byte, block protocol.BlockInfo) error { +func (*sendReceiveFolder) verifyBuffer(buf []byte, block protocol.BlockInfo) error { if len(buf) != int(block.Size) { return fmt.Errorf("length mismatch %d != %d", len(buf), block.Size) } diff --git a/lib/model/model.go b/lib/model/model.go index b1c5a59ab..695f1fd4b 100644 --- a/lib/model/model.go +++ b/lib/model/model.go @@ -1604,7 +1604,7 @@ func (m *model) handleIntroductions(introducerCfg config.DeviceConfiguration, cm } // handleDeintroductions handles removals of devices/shares that are removed by an introducer device -func (m *model) handleDeintroductions(introducerCfg config.DeviceConfiguration, foldersDevices folderDeviceSet, folders map[string]config.FolderConfiguration, devices map[protocol.DeviceID]config.DeviceConfiguration) (map[string]config.FolderConfiguration, map[protocol.DeviceID]config.DeviceConfiguration, bool) { +func (*model) handleDeintroductions(introducerCfg config.DeviceConfiguration, foldersDevices folderDeviceSet, folders map[string]config.FolderConfiguration, devices map[protocol.DeviceID]config.DeviceConfiguration) (map[string]config.FolderConfiguration, map[protocol.DeviceID]config.DeviceConfiguration, bool) { if introducerCfg.SkipIntroductionRemovals { return folders, devices, false } @@ -2777,7 +2777,7 @@ func (m *model) String() string { return fmt.Sprintf("model@%p", m) } -func (m *model) VerifyConfiguration(from, to config.Configuration) error { +func (*model) VerifyConfiguration(from, to config.Configuration) error { toFolders := to.FolderMap() for _, from := range from.Folders { to, ok := toFolders[from.ID] diff --git a/lib/protocol/benchmark_test.go b/lib/protocol/benchmark_test.go index 11647a4ee..31b8f6f4c 100644 --- a/lib/protocol/benchmark_test.go +++ b/lib/protocol/benchmark_test.go @@ -167,11 +167,11 @@ func negotiateTLS(cert tls.Certificate, conn0, conn1 net.Conn) (net.Conn, net.Co type fakeModel struct{} -func (m *fakeModel) Index(_ DeviceID, _ string, _ []FileInfo) error { +func (*fakeModel) Index(_ DeviceID, _ string, _ []FileInfo) error { return nil } -func (m *fakeModel) IndexUpdate(_ DeviceID, _ string, _ []FileInfo) error { +func (*fakeModel) IndexUpdate(_ DeviceID, _ string, _ []FileInfo) error { return nil } @@ -184,13 +184,13 @@ func (m *fakeModel) Request(_ DeviceID, _, _ string, _, size int32, offset int64 return &fakeRequestResponse{buf}, nil } -func (m *fakeModel) ClusterConfig(_ DeviceID, _ ClusterConfig) error { +func (*fakeModel) ClusterConfig(_ DeviceID, _ ClusterConfig) error { return nil } -func (m *fakeModel) Closed(DeviceID, error) { +func (*fakeModel) Closed(DeviceID, error) { } -func (m *fakeModel) DownloadProgress(_ DeviceID, _ string, _ []FileDownloadProgressUpdate) error { +func (*fakeModel) DownloadProgress(_ DeviceID, _ string, _ []FileDownloadProgressUpdate) error { return nil } diff --git a/lib/protocol/bep_extensions.go b/lib/protocol/bep_extensions.go index 078e12216..6d7cbe188 100644 --- a/lib/protocol/bep_extensions.go +++ b/lib/protocol/bep_extensions.go @@ -46,7 +46,7 @@ type FileIntf interface { ModTime() time.Time } -func (m Hello) Magic() uint32 { +func (Hello) Magic() uint32 { return HelloMessageMagic } diff --git a/lib/protocol/common_test.go b/lib/protocol/common_test.go index 9ca9cf985..8299bb970 100644 --- a/lib/protocol/common_test.go +++ b/lib/protocol/common_test.go @@ -32,7 +32,7 @@ func (t *TestModel) Index(deviceID DeviceID, folder string, files []FileInfo) er return nil } -func (t *TestModel) IndexUpdate(_ DeviceID, _ string, _ []FileInfo) error { +func (*TestModel) IndexUpdate(_ DeviceID, _ string, _ []FileInfo) error { return nil } @@ -61,7 +61,7 @@ func (t *TestModel) ClusterConfig(deviceID DeviceID, config ClusterConfig) error return nil } -func (t *TestModel) DownloadProgress(DeviceID, string, []FileDownloadProgressUpdate) error { +func (*TestModel) DownloadProgress(DeviceID, string, []FileDownloadProgressUpdate) error { return nil } @@ -82,6 +82,6 @@ func (r *fakeRequestResponse) Data() []byte { return r.data } -func (r *fakeRequestResponse) Close() {} +func (*fakeRequestResponse) Close() {} -func (r *fakeRequestResponse) Wait() {} +func (*fakeRequestResponse) Wait() {} diff --git a/lib/protocol/encryption.go b/lib/protocol/encryption.go index c78fe2810..c5c66d486 100644 --- a/lib/protocol/encryption.go +++ b/lib/protocol/encryption.go @@ -562,8 +562,8 @@ func (r rawResponse) Data() []byte { return r.data } -func (r rawResponse) Close() {} -func (r rawResponse) Wait() {} +func (rawResponse) Close() {} +func (rawResponse) Wait() {} // IsEncryptedParent returns true if the path points at a parent directory of // encrypted data, i.e. is not a "real" directory. This is determined by diff --git a/lib/rand/securesource.go b/lib/rand/securesource.go index caa1e2c42..8d6e0b75f 100644 --- a/lib/rand/securesource.go +++ b/lib/rand/securesource.go @@ -33,7 +33,7 @@ func newSecureSource() *secureSource { } } -func (s *secureSource) Seed(int64) { +func (*secureSource) Seed(int64) { panic("SecureSource is not seedable") } diff --git a/lib/rc/rc.go b/lib/rc/rc.go index 875ee849e..919631cb3 100644 --- a/lib/rc/rc.go +++ b/lib/rc/rc.go @@ -391,7 +391,7 @@ func (p *Process) Model(folder string) (Model, error) { return res, nil } -func (p *Process) readResponse(resp *http.Response) ([]byte, error) { +func (*Process) readResponse(resp *http.Response) ([]byte, error) { bs, err := io.ReadAll(resp.Body) resp.Body.Close() if err != nil { diff --git a/lib/relay/protocol/packets_xdr.go b/lib/relay/protocol/packets_xdr.go index 924f68414..51c20350c 100644 --- a/lib/relay/protocol/packets_xdr.go +++ b/lib/relay/protocol/packets_xdr.go @@ -31,7 +31,7 @@ struct header { */ -func (o header) XDRSize() int { +func (header) XDRSize() int { return 4 + 4 + 4 } @@ -78,26 +78,26 @@ struct Ping { */ -func (o Ping) XDRSize() int { +func (Ping) XDRSize() int { return 0 } -func (o Ping) MarshalXDR() ([]byte, error) { +func (Ping) MarshalXDR() ([]byte, error) { return nil, nil } -func (o Ping) MustMarshalXDR() []byte { +func (Ping) MustMarshalXDR() []byte { return nil } -func (o Ping) MarshalXDRInto(_ *xdr.Marshaller) error { +func (Ping) MarshalXDRInto(_ *xdr.Marshaller) error { return nil } -func (o *Ping) UnmarshalXDR(_ []byte) error { +func (*Ping) UnmarshalXDR(_ []byte) error { return nil } -func (o *Ping) UnmarshalXDRFrom(_ *xdr.Unmarshaller) error { +func (*Ping) UnmarshalXDRFrom(_ *xdr.Unmarshaller) error { return nil } @@ -112,26 +112,26 @@ struct Pong { */ -func (o Pong) XDRSize() int { +func (Pong) XDRSize() int { return 0 } -func (o Pong) MarshalXDR() ([]byte, error) { +func (Pong) MarshalXDR() ([]byte, error) { return nil, nil } -func (o Pong) MustMarshalXDR() []byte { +func (Pong) MustMarshalXDR() []byte { return nil } -func (o Pong) MarshalXDRInto(_ *xdr.Marshaller) error { +func (Pong) MarshalXDRInto(_ *xdr.Marshaller) error { return nil } -func (o *Pong) UnmarshalXDR(_ []byte) error { +func (*Pong) UnmarshalXDR(_ []byte) error { return nil } -func (o *Pong) UnmarshalXDRFrom(_ *xdr.Unmarshaller) error { +func (*Pong) UnmarshalXDRFrom(_ *xdr.Unmarshaller) error { return nil } @@ -146,26 +146,26 @@ struct JoinRelayRequest { */ -func (o JoinRelayRequest) XDRSize() int { +func (JoinRelayRequest) XDRSize() int { return 0 } -func (o JoinRelayRequest) MarshalXDR() ([]byte, error) { +func (JoinRelayRequest) MarshalXDR() ([]byte, error) { return nil, nil } -func (o JoinRelayRequest) MustMarshalXDR() []byte { +func (JoinRelayRequest) MustMarshalXDR() []byte { return nil } -func (o JoinRelayRequest) MarshalXDRInto(_ *xdr.Marshaller) error { +func (JoinRelayRequest) MarshalXDRInto(_ *xdr.Marshaller) error { return nil } -func (o *JoinRelayRequest) UnmarshalXDR(_ []byte) error { +func (*JoinRelayRequest) UnmarshalXDR(_ []byte) error { return nil } -func (o *JoinRelayRequest) UnmarshalXDRFrom(_ *xdr.Unmarshaller) error { +func (*JoinRelayRequest) UnmarshalXDRFrom(_ *xdr.Unmarshaller) error { return nil } @@ -180,26 +180,26 @@ struct RelayFull { */ -func (o RelayFull) XDRSize() int { +func (RelayFull) XDRSize() int { return 0 } -func (o RelayFull) MarshalXDR() ([]byte, error) { +func (RelayFull) MarshalXDR() ([]byte, error) { return nil, nil } -func (o RelayFull) MustMarshalXDR() []byte { +func (RelayFull) MustMarshalXDR() []byte { return nil } -func (o RelayFull) MarshalXDRInto(_ *xdr.Marshaller) error { +func (RelayFull) MarshalXDRInto(_ *xdr.Marshaller) error { return nil } -func (o *RelayFull) UnmarshalXDR(_ []byte) error { +func (*RelayFull) UnmarshalXDR(_ []byte) error { return nil } -func (o *RelayFull) UnmarshalXDRFrom(_ *xdr.Unmarshaller) error { +func (*RelayFull) UnmarshalXDRFrom(_ *xdr.Unmarshaller) error { return nil } diff --git a/lib/scanner/blocks.go b/lib/scanner/blocks.go index 5009cde7e..84706bb75 100644 --- a/lib/scanner/blocks.go +++ b/lib/scanner/blocks.go @@ -139,4 +139,4 @@ func (noopHash) Write([]byte) (int, error) { return 0, nil } type noopCounter struct{} -func (c *noopCounter) Update(_ int64) {} +func (*noopCounter) Update(_ int64) {} diff --git a/lib/scanner/virtualfs_test.go b/lib/scanner/virtualfs_test.go index 09e0b2c56..bd672bff0 100644 --- a/lib/scanner/virtualfs_test.go +++ b/lib/scanner/virtualfs_test.go @@ -55,7 +55,7 @@ func (i infiniteFS) Open(name string) (fs.File, error) { return &fakeFile{name, i.filesize, 0}, nil } -func (i infiniteFS) PlatformData(_ string) (protocol.PlatformData, error) { +func (infiniteFS) PlatformData(_ string) (protocol.PlatformData, error) { return protocol.PlatformData{}, nil } @@ -101,11 +101,11 @@ func (s singleFileFS) Open(name string) (fs.File, error) { return &fakeFile{s.name, s.filesize, 0}, nil } -func (s singleFileFS) Options() []fs.Option { +func (singleFileFS) Options() []fs.Option { return nil } -func (s singleFileFS) PlatformData(_ string) (protocol.PlatformData, error) { +func (singleFileFS) PlatformData(_ string) (protocol.PlatformData, error) { return protocol.PlatformData{}, nil } @@ -114,17 +114,17 @@ type fakeInfo struct { size int64 } -func (f fakeInfo) Name() string { return f.name } -func (f fakeInfo) Mode() fs.FileMode { return 0755 } -func (f fakeInfo) Size() int64 { return f.size } -func (f fakeInfo) ModTime() time.Time { return time.Unix(1234567890, 0) } +func (f fakeInfo) Name() string { return f.name } +func (fakeInfo) Mode() fs.FileMode { return 0755 } +func (f fakeInfo) Size() int64 { return f.size } +func (fakeInfo) ModTime() time.Time { return time.Unix(1234567890, 0) } func (f fakeInfo) IsDir() bool { return strings.Contains(filepath.Base(f.name), "dir") || f.name == "." } func (f fakeInfo) IsRegular() bool { return !f.IsDir() } -func (f fakeInfo) IsSymlink() bool { return false } -func (f fakeInfo) Owner() int { return 0 } -func (f fakeInfo) Group() int { return 0 } +func (fakeInfo) IsSymlink() bool { return false } +func (fakeInfo) Owner() int { return 0 } +func (fakeInfo) Group() int { return 0 } type fakeFile struct { name string @@ -153,10 +153,10 @@ func (f *fakeFile) Stat() (fs.FileInfo, error) { return fakeInfo{f.name, f.size}, nil } -func (f *fakeFile) Write([]byte) (int, error) { return 0, errNotSupp } -func (f *fakeFile) WriteAt([]byte, int64) (int, error) { return 0, errNotSupp } -func (f *fakeFile) Close() error { return nil } -func (f *fakeFile) Truncate(_ int64) error { return errNotSupp } -func (f *fakeFile) ReadAt([]byte, int64) (int, error) { return 0, errNotSupp } -func (f *fakeFile) Seek(int64, int) (int64, error) { return 0, errNotSupp } -func (f *fakeFile) Sync() error { return nil } +func (*fakeFile) Write([]byte) (int, error) { return 0, errNotSupp } +func (*fakeFile) WriteAt([]byte, int64) (int, error) { return 0, errNotSupp } +func (*fakeFile) Close() error { return nil } +func (*fakeFile) Truncate(_ int64) error { return errNotSupp } +func (*fakeFile) ReadAt([]byte, int64) (int, error) { return 0, errNotSupp } +func (*fakeFile) Seek(int64, int) (int64, error) { return 0, errNotSupp } +func (*fakeFile) Sync() error { return nil } diff --git a/lib/stun/filter.go b/lib/stun/filter.go index 863ab10a4..b33e0f32c 100644 --- a/lib/stun/filter.go +++ b/lib/stun/filter.go @@ -44,7 +44,7 @@ func (f *stunFilter) ClaimIncoming(in []byte, _ net.Addr) bool { return false } -func (f *stunFilter) isStunPayload(data []byte) bool { +func (*stunFilter) isStunPayload(data []byte) bool { // Need at least 20 bytes if len(data) < 20 { return false diff --git a/lib/svcutil/svcutil.go b/lib/svcutil/svcutil.go index 546bea4b8..41dd970a1 100644 --- a/lib/svcutil/svcutil.go +++ b/lib/svcutil/svcutil.go @@ -51,7 +51,7 @@ func (e *FatalErr) Unwrap() error { return e.Err } -func (e *FatalErr) Is(target error) bool { +func (*FatalErr) Is(target error) bool { return target == suture.ErrTerminateSupervisorTree } @@ -76,7 +76,7 @@ func (e *noRestartErr) Unwrap() error { return e.err } -func (e *noRestartErr) Is(target error) bool { +func (*noRestartErr) Is(target error) bool { return target == suture.ErrDoNotRestart } diff --git a/lib/syncthing/verboseservice.go b/lib/syncthing/verboseservice.go index cea602d3f..6f2320485 100644 --- a/lib/syncthing/verboseservice.go +++ b/lib/syncthing/verboseservice.go @@ -50,7 +50,7 @@ func (s *verboseService) Serve(ctx context.Context) error { var folderSummaryRemoveDeprecatedRe = regexp.MustCompile(`(Invalid|IgnorePatterns|StateChanged):\S+\s?`) -func (s *verboseService) formatEvent(ev events.Event) string { +func (*verboseService) formatEvent(ev events.Event) string { switch ev.Type { case events.DownloadProgress, events.LocalIndexUpdated: // Skip diff --git a/lib/testutils/testutils.go b/lib/testutils/testutils.go index ffdf2bfd9..09dc7e805 100644 --- a/lib/testutils/testutils.go +++ b/lib/testutils/testutils.go @@ -45,11 +45,11 @@ func (rw *BlockingRW) Close() error { // NoopRW implements io.Reader and Writer but never returns when called type NoopRW struct{} -func (rw *NoopRW) Read(p []byte) (n int, err error) { +func (*NoopRW) Read(p []byte) (n int, err error) { return len(p), nil } -func (rw *NoopRW) Write(p []byte) (n int, err error) { +func (*NoopRW) Write(p []byte) (n int, err error) { return len(p), nil } diff --git a/lib/ur/contract/contract.go b/lib/ur/contract/contract.go index e4bb52ec2..daae595cb 100644 --- a/lib/ur/contract/contract.go +++ b/lib/ur/contract/contract.go @@ -266,7 +266,7 @@ func (r *Report) FieldPointers() []interface{} { } } -func (r *Report) FieldNames() []string { +func (*Report) FieldNames() []string { // The database fields that back this struct in PostgreSQL return []string{ // V1 diff --git a/lib/ur/failurereporting.go b/lib/ur/failurereporting.go index 91a85cb16..ec20a3e62 100644 --- a/lib/ur/failurereporting.go +++ b/lib/ur/failurereporting.go @@ -195,7 +195,7 @@ func (h *failureHandler) CommitConfiguration(from, to config.Configuration) bool return true } -func (h *failureHandler) String() string { +func (*failureHandler) String() string { return "FailureHandler" } diff --git a/lib/ur/usage_report.go b/lib/ur/usage_report.go index 5c1531399..cd7fb89d8 100644 --- a/lib/ur/usage_report.go +++ b/lib/ur/usage_report.go @@ -328,7 +328,7 @@ func (s *Service) reportData(ctx context.Context, urVersion int, preview bool) ( return report, nil } -func (s *Service) UptimeS() int { +func (*Service) UptimeS() int { return int(time.Since(StartTime).Seconds()) }