#Help with a race condition?
8 messages · Page 1 of 1 (latest)
```go
your code
```
import (
"bufio"
"fmt"
"os"
"sync"
"time"
"github.com/aprice/telnet"
"github.com/aprice/telnet/linereader"
)
func main() {
// conn, err := telnet.Dial("kallistimud.com:4069", ExposeMSDP)
conn, err := telnet.Dial("kallistimud.com:4000")
if err != nil {
return
}
lr := linereader.New()
//go func() {
// fmt.Printf("crank up readline\n")
// err := lr.ReadLines(conn)
// fmt.Printf("finished readline: %v\n", err)
//}()
go lr.ReadLines(conn)
reader := bufio.NewReader(os.Stdin)
go func() {
for {
inp, err := reader.ReadString('\n')
if len(inp) == 0 && err != nil {
break
}
conn.Write([]byte(inp))
}
}()
wg := new(sync.WaitGroup)
wg.Add(1)
go func() {
defer wg.Done()
for {
msg := <-lr.C
fmt.Printf("%v\n", string(msg))
time.Sleep(10 * time.Millisecond)
}
}()
wg.Wait()
}
i think its because theres 2 goroutines that are trying to read from the "lr.c" channel simultaneously
yeah, i found a fork of that module, am trying it now
it seems to work better, found a bug there too
surprised there's not a better telnet-with-IAC support module
just ask ChatGPT (openai)