chore: style fixes from go fix (#10846)
Just `go fix ./...` Signed-off-by: Jakob Borg <jakob@kastelo.net>
This commit is contained in:
@@ -401,7 +401,7 @@ func TestConnectionEstablishment(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func withConnectionPair(b interface{ Fatal(...interface{}) }, connUri string, h func(client, server internalConn)) {
|
||||
func withConnectionPair(b interface{ Fatal(...any) }, connUri string, h func(client, server internalConn)) {
|
||||
// Root of the service tree.
|
||||
supervisor := suture.New("main", suture.Spec{
|
||||
PassThroughPanics: true,
|
||||
@@ -494,7 +494,7 @@ func withConnectionPair(b interface{ Fatal(...interface{}) }, connUri string, h
|
||||
_ = serverConn.Close()
|
||||
}
|
||||
|
||||
func mustGetCert(b interface{ Fatal(...interface{}) }) tls.Certificate {
|
||||
func mustGetCert(b interface{ Fatal(...any) }) tls.Certificate {
|
||||
cert, err := tlsutil.NewCertificateInMemory("bench", 10)
|
||||
if err != nil {
|
||||
b.Fatal(err)
|
||||
|
||||
@@ -54,7 +54,7 @@ func TestDialQueueSort(t *testing.T) {
|
||||
|
||||
var seen1, seen2 int
|
||||
|
||||
for i := 0; i < 100; i++ {
|
||||
for range 100 {
|
||||
queue.Sort()
|
||||
res := shortDevices(queue)
|
||||
if reflect.DeepEqual(res, expected1) {
|
||||
@@ -90,7 +90,7 @@ func TestDialQueueSort(t *testing.T) {
|
||||
|
||||
var seen1, seen2 int
|
||||
|
||||
for i := 0; i < 100; i++ {
|
||||
for range 100 {
|
||||
queue.Sort()
|
||||
res := shortDevices(queue)
|
||||
if reflect.DeepEqual(res, expected1) {
|
||||
|
||||
@@ -256,18 +256,14 @@ func (w *limitedWriter) Write(buf []byte) (int, error) {
|
||||
// try to be a bit adaptable. We range from the minimum write size of 1
|
||||
// KiB up to the limiter burst size, aiming for about a write every
|
||||
// 10ms.
|
||||
singleWriteSize := int(w.waiter.Limit() / 100) // 10ms worth of data
|
||||
singleWriteSize = ((singleWriteSize / 1024) + 1) * 1024 // round up to the next kibibyte
|
||||
if singleWriteSize > limiterBurstSize {
|
||||
singleWriteSize = limiterBurstSize
|
||||
}
|
||||
singleWriteSize := int(w.waiter.Limit() / 100) // 10ms worth of data
|
||||
singleWriteSize = min(
|
||||
// round up to the next kibibyte
|
||||
((singleWriteSize/1024)+1)*1024, limiterBurstSize)
|
||||
|
||||
written := 0
|
||||
for written < len(buf) {
|
||||
toWrite := singleWriteSize
|
||||
if toWrite > len(buf)-written {
|
||||
toWrite = len(buf) - written
|
||||
}
|
||||
toWrite := min(singleWriteSize, len(buf)-written)
|
||||
w.take(toWrite)
|
||||
n, err := w.writer.Write(buf[written : written+toWrite])
|
||||
written += n
|
||||
|
||||
@@ -5,7 +5,6 @@
|
||||
// You can obtain one at https://mozilla.org/MPL/2.0/.
|
||||
|
||||
//go:build go1.15 && !noquic
|
||||
// +build go1.15,!noquic
|
||||
|
||||
package connections
|
||||
|
||||
|
||||
@@ -5,7 +5,6 @@
|
||||
// You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
|
||||
//go:build !noquic
|
||||
// +build !noquic
|
||||
|
||||
package connections
|
||||
|
||||
|
||||
@@ -5,7 +5,6 @@
|
||||
// You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
|
||||
//go:build !noquic
|
||||
// +build !noquic
|
||||
|
||||
package connections
|
||||
|
||||
|
||||
@@ -5,7 +5,6 @@
|
||||
// You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
|
||||
//go:build noquic
|
||||
// +build noquic
|
||||
|
||||
package connections
|
||||
|
||||
|
||||
@@ -18,23 +18,23 @@ import (
|
||||
|
||||
type Registry struct {
|
||||
mut sync.Mutex
|
||||
available map[string][]interface{}
|
||||
available map[string][]any
|
||||
}
|
||||
|
||||
func New() *Registry {
|
||||
return &Registry{
|
||||
available: make(map[string][]interface{}),
|
||||
available: make(map[string][]any),
|
||||
}
|
||||
}
|
||||
|
||||
func (r *Registry) Register(scheme string, item interface{}) {
|
||||
func (r *Registry) Register(scheme string, item any) {
|
||||
r.mut.Lock()
|
||||
defer r.mut.Unlock()
|
||||
|
||||
r.available[scheme] = append(r.available[scheme], item)
|
||||
}
|
||||
|
||||
func (r *Registry) Unregister(scheme string, item interface{}) {
|
||||
func (r *Registry) Unregister(scheme string, item any) {
|
||||
r.mut.Lock()
|
||||
defer r.mut.Unlock()
|
||||
|
||||
@@ -49,12 +49,12 @@ func (r *Registry) Unregister(scheme string, item interface{}) {
|
||||
|
||||
// Get returns an item for a schema compatible with the given scheme.
|
||||
// If any item satisfies preferred, that has precedence over other items.
|
||||
func (r *Registry) Get(scheme string, preferred func(interface{}) bool) interface{} {
|
||||
func (r *Registry) Get(scheme string, preferred func(any) bool) any {
|
||||
r.mut.Lock()
|
||||
defer r.mut.Unlock()
|
||||
|
||||
var (
|
||||
best interface{}
|
||||
best any
|
||||
bestPref bool
|
||||
bestScheme string
|
||||
)
|
||||
|
||||
@@ -14,8 +14,8 @@ import (
|
||||
func TestRegistry(t *testing.T) {
|
||||
r := New()
|
||||
|
||||
want := func(i int) func(interface{}) bool {
|
||||
return func(x interface{}) bool { return x.(int) == i }
|
||||
want := func(i int) func(any) bool {
|
||||
return func(x any) bool { return x.(int) == i }
|
||||
}
|
||||
|
||||
if res := r.Get("int", want(1)); res != nil {
|
||||
@@ -73,7 +73,7 @@ func TestShortSchemeFirst(t *testing.T) {
|
||||
r.Register("foobar", 1)
|
||||
|
||||
// If we don't care about the value, we should get the one with "foo".
|
||||
res := r.Get("foo", func(interface{}) bool { return false })
|
||||
res := r.Get("foo", func(any) bool { return false })
|
||||
if res != 0 {
|
||||
t.Error("unexpected", res)
|
||||
}
|
||||
@@ -89,7 +89,7 @@ func BenchmarkGet(b *testing.B) {
|
||||
b.ResetTimer()
|
||||
|
||||
for i := 0; i < b.N; i++ {
|
||||
r.Get("tcp", func(x interface{}) bool {
|
||||
r.Get("tcp", func(x any) bool {
|
||||
return x.(*net.TCPAddr).IP.IsUnspecified()
|
||||
})
|
||||
}
|
||||
|
||||
@@ -19,6 +19,7 @@ import (
|
||||
"fmt"
|
||||
"io"
|
||||
"log/slog"
|
||||
"maps"
|
||||
"math"
|
||||
"net"
|
||||
"net/url"
|
||||
@@ -817,7 +818,7 @@ func (s *service) createListener(factory listenerFactory, uri *url.URL) bool {
|
||||
}
|
||||
|
||||
func (s *service) logListenAddressesChangedEvent(l ListenerAddresses) {
|
||||
s.evLogger.Log(events.ListenAddressesChanged, map[string]interface{}{
|
||||
s.evLogger.Log(events.ListenAddressesChanged, map[string]any{
|
||||
"address": l.URI,
|
||||
"lan": l.LANAddresses,
|
||||
"wan": l.WANAddresses,
|
||||
@@ -995,9 +996,7 @@ func newConnectionStatusHandler() connectionStatusHandler {
|
||||
func (s *connectionStatusHandler) ConnectionStatus() map[string]ConnectionStatusEntry {
|
||||
result := make(map[string]ConnectionStatusEntry)
|
||||
s.connectionStatusMut.RLock()
|
||||
for k, v := range s.connectionStatus {
|
||||
result[k] = v
|
||||
}
|
||||
maps.Copy(result, s.connectionStatus)
|
||||
s.connectionStatusMut.RUnlock()
|
||||
return result
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user