Skip to content

Commit

Permalink
gofmt && goimports
Browse files Browse the repository at this point in the history
  • Loading branch information
sergiu128 committed Jun 29, 2023
1 parent 20fd3d4 commit 03911f6
Show file tree
Hide file tree
Showing 28 changed files with 74 additions and 50 deletions.
12 changes: 6 additions & 6 deletions byte_buffer.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,12 @@ import (
// - write area: [ri, wi)
//
// A usual workflow is as follows:
// - Bytes are written to the write area. These bytes cannot be read yet.
// - Bytes from the write area are made available for reading in the read area,
// by calling Commit.
// - Bytes from the read area can be either Saved or Consumed. If Saved, the
// bytes are kept in the save area. If Consumed, the bytes' lifetime ends,
// they are automatically discarded. Saved bytes must be discarded later.
// - Bytes are written to the write area. These bytes cannot be read yet.
// - Bytes from the write area are made available for reading in the read area,
// by calling Commit.
// - Bytes from the read area can be either Saved or Consumed. If Saved, the
// bytes are kept in the save area. If Consumed, the bytes' lifetime ends,
// they are automatically discarded. Saved bytes must be discarded later.
//
// Invariants:
// - 0 <= si <= ri <= wi <= min(len(data), cap(b.data)) <= cap(b.data)
Expand Down
3 changes: 2 additions & 1 deletion codec/frame/frame_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,11 @@ package frame

import (
"encoding/binary"
"github.com/talostrading/sonic/sonicerrors"
"math/rand"
"testing"

"github.com/talostrading/sonic/sonicerrors"

"github.com/talostrading/sonic"
)

Expand Down
3 changes: 2 additions & 1 deletion codec/frame/stream_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,13 @@ package frame
import (
"encoding/binary"
"fmt"
"github.com/talostrading/sonic"
"log"
"net"
"sync/atomic"
"testing"
"time"

"github.com/talostrading/sonic"
)

type testServer struct {
Expand Down
3 changes: 2 additions & 1 deletion codec_test.go
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
package sonic

import (
"github.com/talostrading/sonic/sonicerrors"
"net"
"testing"
"time"

"github.com/talostrading/sonic/sonicerrors"
)

var _ Codec[TestItem, TestItem] = &TestCodec{}
Expand Down
3 changes: 2 additions & 1 deletion conn2_test.go
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
package sonic

import (
"github.com/talostrading/sonic/internal"
"net"
"testing"

"github.com/talostrading/sonic/internal"
)

func TestTCPClientDefaultOpts(t *testing.T) {
Expand Down
2 changes: 1 addition & 1 deletion examples/binance/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ var subscriptionMessage = []byte(
var b = make([]byte, 512*1024) // contains websocket payloads

func run(stream websocket.Stream) {
stream.AsyncHandshake("wss://stream.binance.com:9443/ws", func(err error) {
stream.AsyncHandshake("wss://stream.binance.com:9443/ws", func(err error) {
onHandshake(err, stream)
})
}
Expand Down
3 changes: 2 additions & 1 deletion examples/iperf/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,10 @@ The bandwidth results vary greatly with the values set for -l and *n flag below.

import (
"flag"
"log"

"github.com/talostrading/sonic"
"github.com/talostrading/sonic/internal"
"log"
)

var (
Expand Down
5 changes: 3 additions & 2 deletions examples/multicast/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,12 @@ package main
import (
"flag"
"fmt"
"github.com/talostrading/sonic"
"github.com/talostrading/sonic/util"
"log"
"net"
"time"

"github.com/talostrading/sonic"
"github.com/talostrading/sonic/util"
)

var (
Expand Down
12 changes: 7 additions & 5 deletions examples/multicast_peer/rate_reader/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,20 @@ package main
import (
"encoding/binary"
"flag"
"log"
"net/http"
"net/netip"
"time"

"github.com/HdrHistogram/hdrhistogram-go"
"github.com/talostrading/sonic"
"github.com/talostrading/sonic/multicast"
"github.com/talostrading/sonic/sonicerrors"
"github.com/talostrading/sonic/util"
"log"
"net/http"
"net/netip"
"time"

"github.com/felixge/fgprof"
_ "net/http/pprof"

"github.com/felixge/fgprof"
)

var (
Expand Down
7 changes: 4 additions & 3 deletions examples/multicast_peer/rate_writer/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,13 @@ package main
import (
"encoding/binary"
"flag"
"github.com/talostrading/sonic"
"github.com/talostrading/sonic/multicast"
"github.com/talostrading/sonic/util"
"log"
"net/netip"
"time"

"github.com/talostrading/sonic"
"github.com/talostrading/sonic/multicast"
"github.com/talostrading/sonic/util"
)

var (
Expand Down
5 changes: 3 additions & 2 deletions examples/multicast_peer/writer/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,11 @@ package main

import (
"flag"
"github.com/talostrading/sonic"
"github.com/talostrading/sonic/multicast"
"log"
"net/netip"

"github.com/talostrading/sonic"
"github.com/talostrading/sonic/multicast"
)

var (
Expand Down
2 changes: 1 addition & 1 deletion examples/timer/once.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ func main() {
if err != nil {
panic(err)
}
defer timer.Close()
defer timer.Close()

fmt.Println("timer armed: ", time.Now())
err = timer.ScheduleOnce(time.Second, func() {
Expand Down
1 change: 1 addition & 0 deletions examples/udp/conn.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package main

import (
"fmt"

"github.com/talostrading/sonic"
)

Expand Down
3 changes: 2 additions & 1 deletion examples/udp/recv.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,9 @@ package main

import (
"fmt"
"github.com/talostrading/sonic"
"net"

"github.com/talostrading/sonic"
)

func main() {
Expand Down
3 changes: 2 additions & 1 deletion examples/udp/send.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,9 @@ package main

import (
"fmt"
"github.com/talostrading/sonic"
"net"

"github.com/talostrading/sonic"
)

func main() {
Expand Down
7 changes: 4 additions & 3 deletions internal/socket_unix.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,14 @@ package internal
import (
"errors"
"fmt"
"github.com/talostrading/sonic/sonicerrors"
"github.com/talostrading/sonic/sonicopts"
"golang.org/x/sys/unix"
"net"
"os"
"syscall"
"time"

"github.com/talostrading/sonic/sonicerrors"
"github.com/talostrading/sonic/sonicopts"
"golang.org/x/sys/unix"
)

var (
Expand Down
2 changes: 1 addition & 1 deletion internal/timer_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ func (t *Timer) Set(dur time.Duration, cb func()) error {
Value: timespec,
}, nil)
if err == nil {
// TODO error checking here
// TODO error checking here
t.pd.Set(ReadEvent, func(error) {
_, _ = syscall.Read(t.fd, t.b[:])
cb()
Expand Down
5 changes: 3 additions & 2 deletions internal/util_unix.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,12 @@ package internal

import (
"fmt"
"github.com/talostrading/sonic/util"
"golang.org/x/sys/unix"
"net"
"reflect"
"syscall"

"github.com/talostrading/sonic/util"
"golang.org/x/sys/unix"
)

// TODO Handle IPv6
Expand Down
3 changes: 2 additions & 1 deletion listen_conn_test.go
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
package sonic

import (
"github.com/talostrading/sonic/internal"
"net"
"testing"

"github.com/talostrading/sonic/internal"
)

func TestTCPConnListenerDefaultOpts(t *testing.T) {
Expand Down
7 changes: 4 additions & 3 deletions multicast/peer_ipv4_linux_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,16 @@ package multicast

import (
"fmt"
"github.com/talostrading/sonic"
"github.com/talostrading/sonic/net/ipv4"
"github.com/talostrading/sonic/sonicerrors"
"log"
"net/netip"
"sync"
"sync/atomic"
"testing"
"time"

"github.com/talostrading/sonic"
"github.com/talostrading/sonic/net/ipv4"
"github.com/talostrading/sonic/sonicerrors"
)

// TODO: really don't know how to make this run on my mac
Expand Down
7 changes: 4 additions & 3 deletions multicast_udp.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,14 @@ package sonic

import (
"fmt"
"github.com/talostrading/sonic/internal"
"github.com/talostrading/sonic/sonicerrors"
"github.com/talostrading/sonic/sonicopts"
"io"
"net"
"sync/atomic"
"syscall"

"github.com/talostrading/sonic/internal"
"github.com/talostrading/sonic/sonicerrors"
"github.com/talostrading/sonic/sonicopts"
)

// SizeofIPMreqSource I would love to do unsafe.SizeOf but for a struct with 3 4-byte arrays, it returns 8 on my Mac.
Expand Down
5 changes: 3 additions & 2 deletions multicast_udp_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,15 @@
package sonic

import (
"github.com/talostrading/sonic/internal"
"github.com/talostrading/sonic/sonicopts"
"net"
"os"
"sync"
"syscall"
"testing"
"time"

"github.com/talostrading/sonic/internal"
"github.com/talostrading/sonic/sonicopts"
)

var testInterface *net.Interface
Expand Down
3 changes: 2 additions & 1 deletion net/ipv4/multicast_linux.go
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
package ipv4

import (
"github.com/talostrading/sonic"
"syscall"

"github.com/talostrading/sonic"
)

const IP_MULTICAST_ALL = 49 /* grepped torvalds/linux */
Expand Down
5 changes: 3 additions & 2 deletions socket.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,13 @@ package sonic

import (
"fmt"
"github.com/talostrading/sonic/sonicerrors"
"golang.org/x/sys/unix"
"io"
"net"
"net/netip"
"syscall"

"github.com/talostrading/sonic/sonicerrors"
"golang.org/x/sys/unix"
)

type SocketDomain int
Expand Down
5 changes: 3 additions & 2 deletions stress_test/codec/nonblocking.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,11 @@ package main
import (
"flag"
"fmt"
"github.com/talostrading/sonic"
"github.com/talostrading/sonic/codec/frame"
"log"
"time"

"github.com/talostrading/sonic"
"github.com/talostrading/sonic/codec/frame"
)

var (
Expand Down
3 changes: 2 additions & 1 deletion stress_test/codec/server/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,10 @@ package main
import (
"encoding/binary"
"flag"
"log"

"github.com/talostrading/sonic"
"github.com/talostrading/sonic/codec/frame"
"log"
)

var (
Expand Down
3 changes: 2 additions & 1 deletion tests/misc_test.go
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
package tests

import (
"github.com/talostrading/sonic"
"testing"

"github.com/talostrading/sonic"
)

var (
Expand Down
2 changes: 1 addition & 1 deletion timer.go
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ func (t *Timer) ScheduleRepeating(repeat time.Duration, cb func()) error {
if t.cancelled {
t.cancelled = false
} else {
// TODO this error should not be ignored
// TODO this error should not be ignored
_ = t.ScheduleOnce(repeat, ccb)
}
}
Expand Down

0 comments on commit 03911f6

Please sign in to comment.