-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.go
More file actions
35 lines (30 loc) · 789 Bytes
/
Copy pathmain.go
File metadata and controls
35 lines (30 loc) · 789 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
// Copyright (c) 2024 Benedict Weis. All rights reserved.
//
// This work is licensed under the terms of the MIT license.
// For a copy, see <https://opensource.org/licenses/MIT>.
package main
import (
"context"
"log/slog"
"os"
"github.com/benedictweis/tcpchat-server-go/plugin"
)
func main() {
setupLogging()
ctx, cancel := context.WithCancel(context.Background())
defer cancel()
tcpChatServer, err := plugin.NewTCPChatServer("localhost", 8080)
if err != nil {
slog.Error("failed to initialize tcp chat plugin", "err", err)
return
}
err = tcpChatServer.Start(ctx)
if err != nil {
slog.Error("error: failed to start tcp chat plugin", "err", err)
return
}
}
func setupLogging() {
logger := slog.New(slog.NewTextHandler(os.Stdout, nil))
slog.SetDefault(logger)
}