Hi ! I was trying to test a basic irc client with this part of code:
for {
msg, err := tp.ReadLine()
if err != nil {
if errors.Is(err, net.ErrClosed) {
break
}
slog.Error("Readline()", "error", err)
}
fmt.Println(msg)
if strings.HasPrefix(msg, "PING") {
bot.pong(msg)
}
}
but I was wondering how am I supposed to know that the error I can get is net.ErrClosed ?
when I tried to print it using %#v it showed 2026/02/24 12:59:49 &net.OpError{Op:"read", Net:"tcp", Source:(*net.TCPAddr)(0xc00009a960), Addr:(*net.TCPAddr)(0xc00009a990), Err:poll.errNetClosing{}} which doesnt show that specific error name, and poll is an internal package.
and the string representation tells the error but not the name itself.
is there a common/practical/simple way to know what error a function can return ?