Skip to content

Commit 94ffa27

Browse files
committed
Remove dependency on spew
1 parent fa017d7 commit 94ffa27

File tree

8 files changed

+9
-33
lines changed

8 files changed

+9
-33
lines changed

cmd/root.go

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,10 +34,7 @@ var debug bool
3434
// rootCmd represents the base command when called without any subcommands
3535
var rootCmd = &cobra.Command{
3636
Use: "tcp-multiplexer",
37-
Short: "A brief description of your application",
38-
// Uncomment the following line if your bare application
39-
// has an action associated with it:
40-
// Run: func(cmd *cobra.Command, args []string) { },
37+
Short: "Multiplex multiple connections into a single TCP connection.",
4138
}
4239

4340
// Execute adds all child commands to the root command and sets flags appropriately.

example/dummy-iso8583-client/main.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ import (
88
"net"
99
"os"
1010

11-
"github.com/davecgh/go-spew/spew"
1211
"github.com/ingmarstein/tcp-multiplexer/pkg/message"
1312
)
1413

@@ -38,7 +37,7 @@ func main() {
3837
msg, err := message.ISO8583MessageReader{}.ReadMessage(conn)
3938
handleErr(err)
4039

41-
spew.Dump(msg)
40+
fmt.Printf("%x\n", msg)
4241
}
4342
}
4443

example/http-server/main.go

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,6 @@ import (
66
"net/http"
77
"net/http/httputil"
88
"os"
9-
10-
"github.com/davecgh/go-spew/spew"
119
)
1210

1311
func getPort() string {
@@ -23,7 +21,7 @@ func headers(w http.ResponseWriter, req *http.Request) {
2321
if err != nil {
2422
fmt.Println(err)
2523
}
26-
spew.Dump(dump)
24+
fmt.Println(dump)
2725

2826
w.Header().Set("Content-Type", "text/html; charset=utf-8")
2927
w.Write([]byte(html.EscapeString(string(dump))))

go.mod

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,9 @@ module github.com/ingmarstein/tcp-multiplexer
22

33
go 1.23.2
44

5-
require (
6-
github.com/davecgh/go-spew v1.1.1
7-
github.com/spf13/cobra v1.8.1
8-
)
5+
require github.com/spf13/cobra v1.8.1
96

107
require (
118
github.com/inconshreveable/mousetrap v1.1.0 // indirect
12-
github.com/pmezard/go-difflib v1.0.0 // indirect
139
github.com/spf13/pflag v1.0.5 // indirect
14-
gopkg.in/yaml.v3 v3.0.1 // indirect
1510
)

go.sum

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,10 @@
11
github.com/cpuguy83/go-md2man/v2 v2.0.4/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o=
2-
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
3-
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
42
github.com/inconshreveable/mousetrap v1.1.0 h1:wN+x4NVGpMsO7ErUn/mUI3vEoE6Jt13X2s0bqwp9tc8=
53
github.com/inconshreveable/mousetrap v1.1.0/go.mod h1:vpF70FUmC8bwa3OWnCshd2FqLfsEA9PFc4w1p2J65bw=
6-
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
7-
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
84
github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM=
95
github.com/spf13/cobra v1.8.1 h1:e5/vxKd/rZsfSJMUX1agtjeTDf+qv1/JdBF8gg5k9ZM=
106
github.com/spf13/cobra v1.8.1/go.mod h1:wHxEcudfqmLYa8iTfL+OuZPbBZkmvliBWKIezN3kD9Y=
117
github.com/spf13/pflag v1.0.5 h1:iy+VFUOCP1a+8yFto/drg2CJ5u0yRoB7fZw3DKv/JXA=
128
github.com/spf13/pflag v1.0.5/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg=
13-
github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg=
14-
github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY=
15-
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM=
169
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
17-
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
1810
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=

pkg/message/http.go

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,6 @@ import (
1010
"net/textproto"
1111
"strconv"
1212
"strings"
13-
14-
"github.com/davecgh/go-spew/spew"
1513
)
1614

1715
// https://tools.ietf.org/html/rfc2616
@@ -110,7 +108,7 @@ func (H HTTPMessageReader) ReadMessage(conn io.Reader) ([]byte, error) {
110108

111109
msg := dumpHTTPMessage(startLine, headers, body)
112110

113-
slog.Debug(spew.Sdump(msg))
111+
slog.Debug(string(msg))
114112

115113
return msg, err
116114
}

pkg/message/mpu_test.go

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,6 @@ import (
44
"bytes"
55
"fmt"
66
"testing"
7-
8-
"github.com/davecgh/go-spew/spew"
97
)
108

119
func TestMPUMessageReader_ReadMessage(t *testing.T) {
@@ -17,11 +15,11 @@ func TestMPUMessageReader_ReadMessage(t *testing.T) {
1715
buf.WriteByte('a')
1816
}
1917
buf.WriteString("another message")
20-
spew.Dump(buf.Bytes())
18+
fmt.Printf("%x\n", buf)
2119

2220
iso, err := MPUMessageReader{}.ReadMessage(bytes.NewReader(buf.Bytes()))
2321
if err != nil {
2422
t.Fatal("Expected no error, but got:", err)
2523
}
26-
spew.Dump(iso)
24+
fmt.Printf("%x\n", iso)
2725
}

pkg/multiplexer/multiplexer.go

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ import (
88
"sync"
99
"time"
1010

11-
"github.com/davecgh/go-spew/spew"
1211
"github.com/ingmarstein/tcp-multiplexer/pkg/message"
1312
)
1413

@@ -127,7 +126,7 @@ func (mux *Multiplexer) handleConnection(conn net.Conn, sender chan<- *reqContai
127126
break
128127
}
129128

130-
slog.Debug(fmt.Sprintf("Message from client...\n%s", spew.Sdump(msg)))
129+
slog.Debug(fmt.Sprintf("Message from client...\n%x\n", msg))
131130

132131
// enqueue request msg to target conn loop
133132
sender <- &reqContainer{
@@ -234,7 +233,7 @@ func (mux *Multiplexer) targetConnLoop(requestQueue <-chan *reqContainer) {
234233
err: err,
235234
}
236235

237-
slog.Debug(fmt.Sprintf("Message from target server...\n%s", spew.Sdump(msg)))
236+
slog.Debug(fmt.Sprintf("Message from target server...\n%x\n", msg))
238237

239238
if err != nil {
240239
slog.Error(fmt.Sprintf("target connection: %v", err))

0 commit comments

Comments
 (0)