Browse Source

chore: linter: embeddedstructfieldcheck

Signed-off-by: Jakob Borg <[email protected]>
Jakob Borg 3 ngày trước cách đây
mục cha
commit
7c9d06b4d2

+ 1 - 0
cmd/infra/strelaypoolsrv/main.go

@@ -653,6 +653,7 @@ func getLocation(host string, geoip *geoip.Provider) location {
 
 type loggingResponseWriter struct {
 	http.ResponseWriter
+
 	statusCode int
 }
 

+ 1 - 0
cmd/stdiscosrv/amqp.go

@@ -23,6 +23,7 @@ import (
 
 type amqpReplicator struct {
 	suture.Service
+
 	broker   string
 	sender   *amqpSender
 	receiver *amqpReceiver

+ 1 - 0
cmd/stdiscosrv/apisrv.go

@@ -513,6 +513,7 @@ func fixupAddresses(remote *net.TCPAddr, addresses []string) []string {
 
 type loggingResponseWriter struct {
 	http.ResponseWriter
+
 	statusCode int
 }
 

+ 1 - 0
cmd/syncthing/cli/client.go

@@ -32,6 +32,7 @@ type APIClient interface {
 
 type apiClient struct {
 	http.Client
+
 	cfg    config.GUIConfiguration
 	apikey string
 }

+ 1 - 0
internal/db/sqlite/db_prepared.go

@@ -10,6 +10,7 @@ import "github.com/jmoiron/sqlx"
 
 type txPreparedStmts struct {
 	*sqlx.Tx
+
 	stmts map[string]*sqlx.Stmt
 }
 

+ 2 - 1
internal/db/sqlite/folderdb_open.go

@@ -14,9 +14,10 @@ import (
 )
 
 type folderDB struct {
-	folderID string
 	*baseDB
 
+	folderID string
+
 	localDeviceIdx  int64
 	deleteRetention time.Duration
 }

+ 1 - 0
lib/api/confighandler.go

@@ -22,6 +22,7 @@ import (
 
 type configMuxBuilder struct {
 	*httprouter.Router
+
 	id  protocol.DeviceID
 	cfg config.Wrapper
 }

+ 1 - 0
lib/beacon/beacon.go

@@ -32,6 +32,7 @@ type Interface interface {
 
 type cast struct {
 	*suture.Supervisor
+
 	name    string
 	reader  svcutil.ServiceWithError
 	writer  svcutil.ServiceWithError

+ 1 - 0
lib/config/config.go

@@ -165,6 +165,7 @@ func (cfg *Configuration) ProbeFreePorts() error {
 
 type xmlConfiguration struct {
 	Configuration
+
 	XMLName xml.Name `xml:"configuration"`
 }
 

+ 2 - 0
lib/connections/deprecated.go

@@ -11,6 +11,7 @@ import "github.com/syncthing/syncthing/lib/config"
 // invalidListener is never valid
 type invalidListener struct {
 	listenerFactory
+
 	err error
 }
 
@@ -25,6 +26,7 @@ func (i invalidListener) Valid(_ config.Configuration) error {
 // invalidDialer is never valid
 type invalidDialer struct {
 	dialerFactory
+
 	err error
 }
 

+ 4 - 2
lib/connections/limiter.go

@@ -225,8 +225,9 @@ func getRateLimiter(m map[protocol.DeviceID]*rate.Limiter, deviceID protocol.Dev
 
 // limitedReader is a rate limited io.Reader
 type limitedReader struct {
-	reader io.Reader
 	waiterHolder
+
+	reader io.Reader
 }
 
 func (r *limitedReader) Read(buf []byte) (int, error) {
@@ -239,8 +240,9 @@ func (r *limitedReader) Read(buf []byte) (int, error) {
 
 // limitedWriter is a rate limited io.Writer
 type limitedWriter struct {
-	writer io.Writer
 	waiterHolder
+
+	writer io.Writer
 }
 
 func (w *limitedWriter) Write(buf []byte) (int, error) {

+ 1 - 0
lib/connections/quic_dial.go

@@ -39,6 +39,7 @@ func init() {
 
 type quicDialer struct {
 	commonDialer
+
 	registry *registry.Registry
 }
 

+ 2 - 2
lib/connections/quic_listen.go

@@ -39,10 +39,10 @@ func init() {
 
 type quicListener struct {
 	svcutil.ServiceWithError
-	nat atomic.Uint64 // Holds a stun.NATType.
-
 	onAddressesChangedNotifier
 
+	nat atomic.Uint64 // Holds a stun.NATType.
+
 	uri        *url.URL
 	cfg        config.Wrapper
 	tlsCfg     *tls.Config

+ 1 - 0
lib/connections/quic_misc.go

@@ -42,6 +42,7 @@ func quicNetwork(uri *url.URL) string {
 type quicTlsConn struct {
 	quic.Connection
 	quic.Stream
+
 	// If we created this connection, we should be the ones closing it.
 	createdConn net.PacketConn
 }

+ 1 - 0
lib/connections/structs.go

@@ -39,6 +39,7 @@ type tlsConn interface {
 // came from (type, priority).
 type internalConn struct {
 	tlsConn
+
 	connType      connType
 	isLocal       bool
 	priority      int

+ 1 - 0
lib/connections/tcp_dial.go

@@ -27,6 +27,7 @@ func init() {
 
 type tcpDialer struct {
 	commonDialer
+
 	registry *registry.Registry
 }
 

+ 1 - 0
lib/dialer/internal.go

@@ -64,6 +64,7 @@ func socksDialerFunction(u *url.URL, forward proxy.Dialer) (proxy.Dialer, error)
 // existing connection" shenanigans.
 type dialerConn struct {
 	net.Conn
+
 	addr net.Addr
 }
 

+ 1 - 0
lib/discover/cache.go

@@ -17,6 +17,7 @@ import (
 // A cachedFinder is a Finder with associated cache timeouts.
 type cachedFinder struct {
 	Finder
+
 	cacheTime    time.Duration
 	negCacheTime time.Duration
 	cache        *cache

+ 3 - 1
lib/discover/global.go

@@ -32,6 +32,8 @@ import (
 )
 
 type globalClient struct {
+	errorHolder
+
 	server         string
 	addrList       AddressLister
 	announceClient httpClient
@@ -39,7 +41,6 @@ type globalClient struct {
 	noAnnounce     bool
 	noLookup       bool
 	evLogger       events.Logger
-	errorHolder
 }
 
 type httpClient interface {
@@ -373,6 +374,7 @@ func queryBool(q url.Values, key string) bool {
 
 type idCheckingHTTPClient struct {
 	httpClient
+
 	id protocol.DeviceID
 }
 

+ 2 - 2
lib/discover/local.go

@@ -34,6 +34,8 @@ import (
 
 type localClient struct {
 	*suture.Supervisor
+	*cache
+
 	myID     protocol.DeviceID
 	addrList AddressLister
 	name     string
@@ -43,8 +45,6 @@ type localClient struct {
 	localBcastStart time.Time
 	localBcastTick  <-chan time.Time
 	forcedBcastTick chan time.Time
-
-	*cache
 }
 
 const (

+ 1 - 0
lib/discover/manager.go

@@ -41,6 +41,7 @@ type Manager interface {
 
 type manager struct {
 	*suture.Supervisor
+
 	myID          protocol.DeviceID
 	cfg           config.Wrapper
 	cert          tls.Certificate

+ 1 - 0
lib/fs/basicfs.go

@@ -340,6 +340,7 @@ func (*BasicFilesystem) underlying() (Filesystem, bool) {
 // basicFile implements the fs.File interface on top of an os.File
 type basicFile struct {
 	*os.File
+
 	name string
 }
 

+ 1 - 0
lib/fs/fakefs.go

@@ -749,6 +749,7 @@ func (fs *fakeFS) reportMetricsPer(b *testing.B, divisor float64, unit string) {
 // opened for reading or writing, it's all good.
 type fakeFile struct {
 	*fakeEntry
+
 	mut           *sync.Mutex
 	rng           io.Reader
 	seed          int64

+ 1 - 0
lib/fs/logfs.go

@@ -16,6 +16,7 @@ import (
 
 type logFilesystem struct {
 	Filesystem
+
 	// Number of filesystem layers on top of logFilesystem to skip when looking
 	// for the true caller of the filesystem
 	layers int

+ 3 - 0
lib/fs/mtimefs.go

@@ -19,6 +19,7 @@ type database interface {
 
 type mtimeFS struct {
 	Filesystem
+
 	chtimes         func(string, time.Time, time.Time) error
 	db              database
 	folderID        string
@@ -170,6 +171,7 @@ func (f *mtimeFS) load(name string) (ondisk, virtual time.Time) {
 
 type mtimeFileInfo struct {
 	FileInfo
+
 	mtime time.Time
 }
 
@@ -179,6 +181,7 @@ func (m mtimeFileInfo) ModTime() time.Time {
 
 type mtimeFile struct {
 	File
+
 	fs *mtimeFS
 }
 

+ 1 - 0
lib/fs/walkfs.go

@@ -63,6 +63,7 @@ type WalkFunc func(path string, info FileInfo, err error) error
 
 type walkFilesystem struct {
 	Filesystem
+
 	checkInfiniteRecursion bool
 }
 

+ 1 - 0
lib/model/folder.go

@@ -44,6 +44,7 @@ type folder struct {
 	stateTracker
 	config.FolderConfiguration
 	*stats.FolderStatisticsReference
+
 	ioLimiter *semaphore.Semaphore
 
 	localFlags protocol.FlagLocal

+ 2 - 0
lib/model/folder_sendrecv.go

@@ -48,6 +48,7 @@ func init() {
 // to be fetched.
 type pullBlockState struct {
 	*sharedPullerState
+
 	block protocol.BlockInfo
 }
 
@@ -55,6 +56,7 @@ type pullBlockState struct {
 // copied.
 type copyBlocksState struct {
 	*sharedPullerState
+
 	blocks []protocol.BlockInfo
 	have   int
 }

+ 2 - 0
lib/model/model.go

@@ -690,6 +690,7 @@ type ConnectionStats struct {
 
 type ConnectionInfo struct {
 	protocol.Statistics
+
 	Address string `json:"address"`
 	Type    string `json:"type"`
 	IsLocal bool   `json:"isLocal"`
@@ -3484,6 +3485,7 @@ func redactPathError(err error) (error, bool) {
 
 type redactedError struct {
 	error
+
 	redacted error
 }
 

+ 2 - 0
lib/protocol/counting.go

@@ -14,6 +14,7 @@ import (
 
 type countingReader struct {
 	io.Reader
+
 	idString string
 	tot      atomic.Int64 // bytes
 	last     atomic.Int64 // unix nanos
@@ -41,6 +42,7 @@ func (c *countingReader) Last() time.Time {
 
 type countingWriter struct {
 	io.Writer
+
 	idString string
 	tot      atomic.Int64 // bytes
 	last     atomic.Int64 // unix nanos

+ 1 - 0
lib/protocol/encryption.go

@@ -171,6 +171,7 @@ func (e encryptedModel) Closed(err error) {
 // encrypts outgoing metadata and decrypts incoming responses.
 type encryptedConnection struct {
 	ConnectionInfo
+
 	conn       *rawConnection
 	folderKeys *folderKeyRegistry
 	keyGen     *KeyGenerator

+ 1 - 0
lib/relay/client/client.go

@@ -38,6 +38,7 @@ func NewClient(uri *url.URL, certs []tls.Certificate, timeout time.Duration) (Re
 
 type commonClient struct {
 	svcutil.ServiceWithError
+
 	invitations chan protocol.SessionInvitation
 }
 

+ 3 - 2
lib/scanner/walk.go

@@ -681,9 +681,10 @@ func (w *walker) String() string {
 // A byteCounter gets bytes added to it via Update() and then provides the
 // Total() and one minute moving average Rate() in bytes per second.
 type byteCounter struct {
-	total atomic.Int64
 	metrics.EWMA
-	stop chan struct{}
+
+	total atomic.Int64
+	stop  chan struct{}
 }
 
 func newByteCounter() *byteCounter {

+ 3 - 1
lib/tlsutil/tlsutil.go

@@ -200,6 +200,7 @@ func NewCertificateInMemory(commonName string, lifetimeDays int) (tls.Certificat
 
 type DowngradingListener struct {
 	net.Listener
+
 	TLSConfig *tls.Config
 }
 
@@ -244,9 +245,10 @@ func (l *DowngradingListener) AcceptNoWrapTLS() (net.Conn, bool, error) {
 }
 
 type UnionedConnection struct {
+	net.Conn
+
 	first     [1]byte
 	firstDone bool
-	net.Conn
 }
 
 func (c *UnionedConnection) Read(b []byte) (n int, err error) {

+ 1 - 0
lib/ur/failurereporting.go

@@ -41,6 +41,7 @@ var (
 
 type FailureReport struct {
 	FailureData
+
 	Count   int
 	Version string
 }

+ 1 - 0
lib/versioner/versioner.go

@@ -55,6 +55,7 @@ func New(cfg config.FolderConfiguration) (Versioner, error) {
 
 type versionerWithErrorContext struct {
 	Versioner
+
 	vtype string
 }