aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSam Anthony <sam@samanthony.xyz>2025-04-11 13:51:34 -0400
committerSam Anthony <sam@samanthony.xyz>2025-04-11 13:51:34 -0400
commit84b7e4b1c020c493c605d116570d3d8e5c0b3256 (patch)
treef6d75d87e42f6c124c8017b84863e4bb0e9bf06c
parentcf59ee3ec4b5233910de4f67b38fab3e4df7d5fb (diff)
downloadhose-84b7e4b1c020c493c605d116570d3d8e5c0b3256.zip
logf(): print newline
-rw-r--r--main.go17
1 files changed, 9 insertions, 8 deletions
diff --git a/main.go b/main.go
index 8dfa550..d2d942b 100644
--- a/main.go
+++ b/main.go
@@ -31,7 +31,7 @@ func main() {
eprintf("%v\n", err)
}
} else {
- logf("%s\n", usage)
+ logf("%s", usage)
flag.Usage()
os.Exit(1)
}
@@ -45,33 +45,33 @@ func recv() error {
return err
}
defer ln.Close()
- logf("listening on %s\n", laddr)
+ logf("listening on %s", laddr)
conn, err := ln.Accept()
if err != nil {
return err
}
defer conn.Close()
- logf("accepted connection from %s\n", conn.RemoteAddr())
+ logf("accepted connection from %s", conn.RemoteAddr())
n, err := io.Copy(os.Stdout, conn)
- logf("received %.2f\n", units.Bytes(n)*units.B)
+ logf("received %.2f", units.Bytes(n)*units.B)
return err
}
// send pipes data from stdin to the remote host.
func send(rhost string) error {
raddr := net.JoinHostPort(rhost, port)
- logf("connecting to %s...\n", raddr)
+ logf("connecting to %s...", raddr)
conn, err := net.Dial(network, raddr)
if err != nil {
return err
}
defer conn.Close()
- logf("connected to %s\n", raddr)
+ logf("connected to %s", raddr)
n, err := io.Copy(conn, os.Stdin)
- logf("sent %.2f\n", units.Bytes(n)*units.B)
+ logf("sent %.2f", units.Bytes(n)*units.B)
return err
}
@@ -81,5 +81,6 @@ func eprintf(format string, a ...any) {
}
func logf(format string, a ...any) {
- fmt.Fprintf(os.Stderr, format, a...)
+ msg := fmt.Sprintf(format, a...)
+ fmt.Fprintf(os.Stderr, "%s\n", msg)
}