Redis-cli prompt appears in the same line as response from INFO command

I’m doing Stage #YE5 of the redis challange.

When my response gets printed by the redis-cli app, the prompt for the next command gets printed on the same line as the last line of my response, as opposed to a new line.

I’ve cut down the response to just return the line role master and I’ve tried sending back just a simple string vs a bulk string. The weird thing is that it only happens when I run the INFO command and not any other commands.

> redis-cli
127.0.0.1:6379> ping
PONG
127.0.0.1:6379> info replication
role:master127.0.0.1:6379> 
// Create resp response
func info(args []*RESP) *RESP {
	if len(args) != 1 {
		return NullResp()
	}
	switch args[0].Value {
	case "replication":
		return &RESP{
			Type:  BULK,
			Value: "role:" + ThisServer.Type.String(),
		}
	default:
		return NullResp()
	}
}

// Serialize RESP response
func (resp *RESP) marshalBulk() (bytes []byte) {
	bytes = append(bytes, BULK)
	bytes = strconv.AppendInt(bytes, int64(len((resp.Value))), 10)
	bytes = append(bytes, CRLF...)
	bytes = append(bytes, resp.Value...)
	bytes = append(bytes, CRLF...)
	return bytes
}

// For reference of the above var/constants
BULK    = '$'
var CRLF = []byte("\r\n")

@elordeiro just checking, do you still need any assistance with this?

Closing this thread due to inactivity. If you still need assistance, feel free to reopen or start a new discussion!

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