Problem Submitting

I’m stuck on Stage #wy1

My solution is this, which looks almost the solutions provided in Code Examples, but I get error:

package main

import (
	"bufio"
	"fmt"
	"net"
	"os"
	"strings"
)

// 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", ":6379")
	if err != nil {
		fmt.Println("Failed to bind to port 6379")
		os.Exit(1)
	}

	for {
		conn, err := l.Accept()
		if err != nil {
			fmt.Println(err)
			continue
		}

		go handleConnection(conn)
	}
}

func handleConnection(conn net.Conn) {
	defer conn.Close()

	scanner := bufio.NewScanner(conn)
	for scanner.Scan() {
		text := scanner.Text()

		if strings.TrimSpace(text) == "PING" {
			conn.Write([]byte("+PONG\r\n"))
		}
	}
}

Here are my logs:

remote: [your_program] Logs from your program will appear here!
remote: [tester::#WY1] [client-1] $ redis-cli PING
remote: [tester::#WY1] [client-1] Received "PONG"
remote: [tester::#WY1] [client-1] > PING
remote: [tester::#WY1] write tcp [::1]:36870->[::1]:6379: write: broken pipe
remote: [tester::#WY1] Test failed (try setting 'debug: true' in your codecrafters.yml to see more details)
remote: 

Hey @kevinbg012, could you check if you’ve committed and pushed your latest code? It looks like the version on our server does not include your recent changes.

Could you try running git status and share the result?

You can also upload your code (from our server) to GitHub, and compare it with what’s on your local machine.

Oh sorry, I wasn’t commiting all changes. Thanks for your help

1 Like

This topic was automatically closed 5 days after the last reply. New replies are no longer allowed.