From 0035c6f152f6291d2a5c16c3a06e7deb03843c98 Mon Sep 17 00:00:00 2001 From: Jacob Date: Sun, 14 Apr 2024 17:23:12 +0200 Subject: [PATCH] Format code using gofumpt --- examples/recv-dir/recv-dir.go | 2 +- .../rendezvousservertest/rendezvousservertest.go | 2 -- wormhole/file_transport.go | 2 +- wormhole/recv.go | 2 +- wormhole/send.go | 1 - wormhole/wormhole.go | 3 +-- wormhole/wormhole_test.go | 10 +++++----- 7 files changed, 9 insertions(+), 13 deletions(-) diff --git a/examples/recv-dir/recv-dir.go b/examples/recv-dir/recv-dir.go index c10c2910..a6d39e87 100644 --- a/examples/recv-dir/recv-dir.go +++ b/examples/recv-dir/recv-dir.go @@ -71,7 +71,7 @@ func main() { } dir := filepath.Dir(p) - err = os.MkdirAll(dir, 0777) + err = os.MkdirAll(dir, 0o777) if err != nil { log.Fatalf("Failed to mkdirall %s: %s", dir, err) } diff --git a/rendezvous/rendezvousservertest/rendezvousservertest.go b/rendezvous/rendezvousservertest/rendezvousservertest.go index 98f1801d..bb746802 100644 --- a/rendezvous/rendezvousservertest/rendezvousservertest.go +++ b/rendezvous/rendezvousservertest/rendezvousservertest.go @@ -51,14 +51,12 @@ func (ts *TestServer) WebSocketURL() string { u, err := url.Parse(ts.URL) if err != nil { panic(err) - } u.Scheme = "ws" u.Path = "/ws" return u.String() - } type mailbox struct { diff --git a/wormhole/file_transport.go b/wormhole/file_transport.go index a7842be5..14ff89aa 100644 --- a/wormhole/file_transport.go +++ b/wormhole/file_transport.go @@ -79,6 +79,7 @@ func newTransportCryptor(c net.Conn, transitKey []byte, readPurpose, writePurpos writeKey: writeKey, } } + func (d *transportCryptor) Close() error { return d.conn.Close() } @@ -293,7 +294,6 @@ func (t *fileTransport) connectToRelay(ctx context.Context, addr string, success func (t *fileTransport) connectToSingleHost(ctx context.Context, addr string, successChan chan net.Conn, failChan chan string) { var d net.Dialer conn, err := d.DialContext(ctx, "tcp", addr) - if err != nil { failChan <- addr return diff --git a/wormhole/recv.go b/wormhole/recv.go index 178e98f7..04129601 100644 --- a/wormhole/recv.go +++ b/wormhole/recv.go @@ -176,7 +176,7 @@ func (c *Client) Receive(ctx context.Context, code string) (fr *IncomingMessage, rc.Close(ctx, mood) }() - var errStr = "transfer rejected" + errStr := "transfer rejected" answer := &genericMessage{ Error: &errStr, } diff --git a/wormhole/send.go b/wormhole/send.go index 44b4e44a..2e2d1c51 100644 --- a/wormhole/send.go +++ b/wormhole/send.go @@ -601,7 +601,6 @@ func readSeekerSize(r io.ReadSeeker) (int64, error) { } return size, nil - } type sendOptions struct { diff --git a/wormhole/wormhole.go b/wormhole/wormhole.go index daec3a04..dfa44d58 100644 --- a/wormhole/wormhole.go +++ b/wormhole/wormhole.go @@ -241,8 +241,7 @@ type genericMessage struct { Error *string `json:"error,omitempty"` } -type appVersionsMsg struct { -} +type appVersionsMsg struct{} type answerMsg struct { MessageAck string `json:"message_ack,omitempty"` diff --git a/wormhole/wormhole_test.go b/wormhole/wormhole_test.go index a2ef2a5f..414a5886 100644 --- a/wormhole/wormhole_test.go +++ b/wormhole/wormhole_test.go @@ -332,7 +332,7 @@ func TestWormholeBigFileTransportSendRecvViaRelayServer(t *testing.T) { // skip th wrapper so we can provide our own offer code, _, err := c0.sendFileDirectory(ctx, offer, io.NopCloser(r)) - //c0.SendFile(ctx, "file.txt", buf) + // c0.SendFile(ctx, "file.txt", buf) if err != nil { t.Fatal(err) } @@ -345,7 +345,6 @@ func TestWormholeBigFileTransportSendRecvViaRelayServer(t *testing.T) { if int64(receiver.TransferBytes) != fakeBigSize { t.Fatalf("Mismatch in size between what we are trying to send and what is (our parsed) offer. Expected %v but got %v", fakeBigSize, receiver.TransferBytes) } - } func TestWormholeFileTransportRecvMidStreamCancel(t *testing.T) { @@ -947,8 +946,10 @@ func (ts *testRelayServer) run() { } } -var headerPrefix = []byte("please relay ") -var headerSide = []byte(" for side ") +var ( + headerPrefix = []byte("please relay ") + headerSide = []byte(" for side ") +) func (ts *testRelayServer) handleConn(c net.Conn) { // requests look like: @@ -1036,7 +1037,6 @@ func (ts *testRelayServer) handleConn(c net.Conn) { io.Copy(c, existing) existing.Close() c.Close() - }() io.Copy(existing, c)