moved the kafka-go project to this repository
This commit is contained in:
@@ -0,0 +1,37 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"net"
|
||||
"os"
|
||||
|
||||
protocol "github.com/codecrafters-io/redis-starter-go/app/protocol/response"
|
||||
)
|
||||
|
||||
// Ensures gofmt doesn't remove the "net" and "os" imports in stage 1 (feel free to remove this!)
|
||||
var _ = net.Listen
|
||||
var _ = os.Exit
|
||||
|
||||
func main() {
|
||||
|
||||
l, err := net.Listen("tcp", "0.0.0.0:9092")
|
||||
if err != nil {
|
||||
fmt.Println("Failed to bind to port 9092: ", err.Error())
|
||||
os.Exit(1)
|
||||
}
|
||||
conn, err := l.Accept()
|
||||
if err != nil {
|
||||
fmt.Println("Could not accept connection: ", err.Error())
|
||||
os.Exit(1)
|
||||
}
|
||||
defer conn.Close()
|
||||
|
||||
if _, err = conn.Read(make([]byte, 1024)); err != nil {
|
||||
fmt.Println("Failed to read request: ", err.Error())
|
||||
}
|
||||
|
||||
response := protocol.NewV0Reponse(7)
|
||||
if _, err = conn.Write(response.ToBytes()); err != nil {
|
||||
fmt.Println("Failed to write response: ", err.Error())
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user