Skip to content

Commit 2a5bb4d

Browse files
author
Steven Noonan
committed
trivial_signaling_server: run through gofmt
It's a good idea to follow the golang prescribed formatting. Signed-off-by: Steven Noonan <[email protected]>
1 parent 9e13829 commit 2a5bb4d

File tree

1 file changed

+15
-16
lines changed

1 file changed

+15
-16
lines changed

examples/trivial_signaling_server.go

Lines changed: 15 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -40,12 +40,12 @@
4040
package main
4141

4242
import (
43-
"strings"
44-
"fmt"
45-
"net"
46-
"flag"
4743
"bufio"
44+
"flag"
45+
"fmt"
4846
"log"
47+
"net"
48+
"strings"
4949
)
5050

5151
const DEFAULT_LISTEN_PORT = 10000
@@ -64,9 +64,9 @@ func ServiceConnection(conn net.Conn) {
6464

6565
// In our trivial protocol, the first line contains the client identity
6666
// on a line by itself
67-
intro,err := in.ReadString('\n')
67+
intro, err := in.ReadString('\n')
6868
if err != nil {
69-
log.Printf( "[%s] Aborting connection before we ever received client identity", addr )
69+
log.Printf("[%s] Aborting connection before we ever received client identity", addr)
7070
conn.Close()
7171
}
7272
identity := strings.TrimSpace(intro)
@@ -81,26 +81,26 @@ func ServiceConnection(conn net.Conn) {
8181

8282
// Now handle existing entry
8383
if existingConn != nil {
84-
log.Printf( "[%s@%s] Closing connection to make room for new connection from '%s'", identity, existingConn.RemoteAddr().String(), addr )
84+
log.Printf("[%s@%s] Closing connection to make room for new connection from '%s'", identity, existingConn.RemoteAddr().String(), addr)
8585
existingConn.Close()
8686
}
87-
log.Printf( "[%s@%s] Added connection", identity, addr )
87+
log.Printf("[%s@%s] Added connection", identity, addr)
8888

8989
// Keep reading until connection is closed
9090
for {
91-
line,err := in.ReadString('\n')
91+
line, err := in.ReadString('\n')
9292
if err != nil {
9393
conn.Close()
9494

9595
// Are we stil in the map?
9696
if g_mapClientConnections[identity] == conn {
97-
log.Printf( "[%s@%s] Connecton closed. %s", identity, addr, err )
97+
log.Printf("[%s@%s] Connecton closed. %s", identity, addr, err)
9898
delete(g_mapClientConnections, identity)
9999
} else {
100100
// Assume it's because we got replaced by another connection.
101101
// The other connection already logged, so don't do anything here
102102
}
103-
break;
103+
break
104104
}
105105

106106
// Our protocol is just [destination peer identity] [payload]
@@ -110,7 +110,7 @@ func ServiceConnection(conn net.Conn) {
110110
log.Printf("[%s@%s] Ignoring weird input '%s' (maybe truncated?)", identity, addr, line)
111111
continue
112112
}
113-
dest_identity := strings.TrimSpace(dest_and_msg[0]);
113+
dest_identity := strings.TrimSpace(dest_and_msg[0])
114114
payload := dest_and_msg[1]
115115

116116
// Locate the destination peer's connection.
@@ -135,9 +135,9 @@ func ServiceConnection(conn net.Conn) {
135135
// Main entry point
136136
func main() {
137137

138-
// Parse command line flags
138+
// Parse command line flags
139139
port := flag.Int("port", DEFAULT_LISTEN_PORT, "Port to listen on")
140-
flag.Parse()
140+
flag.Parse()
141141
listen_addr := fmt.Sprintf("0.0.0.0:%d", *port)
142142

143143
// Start listening
@@ -151,7 +151,7 @@ func main() {
151151
for {
152152

153153
// Wait for the next incoming connection
154-
conn,err := listener.Accept()
154+
conn, err := listener.Accept()
155155
if err != nil {
156156
log.Panic(err)
157157
}
@@ -161,4 +161,3 @@ func main() {
161161
}
162162

163163
}
164-

0 commit comments

Comments
 (0)