Skip to content

Commit 3d5cb81

Browse files
committed
github actions added
1 parent d2c786b commit 3d5cb81

4 files changed

Lines changed: 73 additions & 7 deletions

File tree

.DS_Store

6 KB
Binary file not shown.

.github/workflows/ci.yml

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
branches: [ main ]
6+
pull_request:
7+
branches: [ main ]
8+
9+
jobs:
10+
test:
11+
runs-on: ubuntu-latest
12+
strategy:
13+
matrix:
14+
go-version: ['1.25']
15+
16+
steps:
17+
- uses: actions/checkout@v4
18+
19+
- name: Set up Go
20+
uses: actions/setup-go@v4
21+
with:
22+
go-version: ${{ matrix.go-version }}
23+
24+
- name: Download dependencies
25+
run: go mod tidy
26+
27+
- name: Verify dependencies
28+
run: go mod verify
29+
30+
- name: Build
31+
run: go build -v ./...
32+
33+
- name: Run tests (if any exist)
34+
run: |
35+
if find . -name "*_test.go" | grep -q .; then
36+
go test -v -race ./...
37+
else
38+
echo "No tests found, skipping test execution"
39+
fi
40+
41+
lint:
42+
runs-on: ubuntu-latest
43+
steps:
44+
- uses: actions/checkout@v4
45+
46+
- name: Set up Go
47+
uses: actions/setup-go@v4
48+
with:
49+
go-version: '1.25'
50+
51+
- name: golangci-lint
52+
uses: golangci/golangci-lint-action@v3
53+
with:
54+
version: latest
55+
args: --timeout=5m

Makefile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
run:
2+
go run ./cmd/tcplistener/

main.go renamed to cmd/tcplistener/main.go

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ package main
33
import (
44
"fmt"
55
"io"
6-
"os"
6+
"net"
77
"strings"
88
)
99

@@ -51,17 +51,26 @@ func getLinesChannel(f io.ReadCloser) <-chan string {
5151
}
5252

5353
func main() {
54-
file, err := os.Open("./messages.txt")
54+
listener, err := net.Listen("tcp", ":42069")
5555

5656
if err != nil {
5757
fmt.Println("Error Happend", err.Error())
5858
}
5959

60-
lines := getLinesChannel(file)
60+
defer listener.Close()
6161

62-
for val := range lines {
63-
fmt.Println("read: ", val)
64-
}
62+
for {
63+
conn, err := listener.Accept()
64+
if err != nil {
65+
fmt.Println(err.Error())
66+
}
67+
68+
go func(c net.Conn) {
69+
lines := getLinesChannel(conn)
6570

66-
fmt.Println("DONE")
71+
for line := range lines {
72+
fmt.Println(line)
73+
}
74+
}(conn)
75+
}
6776
}

0 commit comments

Comments
 (0)