Closed amanhasank closed 7 months ago
Hi, i am trying to use StartAddr, Please see below code snippet
func TestSomething(t *testing.T) {
// Run the miniredis server
s := miniredis.NewMiniRedis()
port := 6370
s.StartAddr(fmt.Sprintf(":%d", port))
err := s.Start()
if err != nil {
fmt.Println("Error starting Miniredis:", err)
return
}
}
but i am getting === RUN TestSomething Error starting Miniredis: listen tcp 127.0.0.1:6370: bind: address already in use
even though this port is free lsof -i :6370
i have also tried using different port numbers still the same error, Am i using it correctly or something is missed here?
Thanks, that sounds weird. Can't have a look right now but will try soon(ish).
thanks.
s.StartAddr(fmt.Sprintf(":%d", port))
err := s.Start()
you only need one of the Start...
calls. So remove the s.Start()
call and then it's:
err := s.StartAddr(fmt.Sprintf(":%d", port))
That Works, thanks a lot.
Should do what you want.