R
R
Roman Mirilaczvili2020-06-20 21:25:08
go
Roman Mirilaczvili, 2020-06-20 21:25:08

How to catch network errors in Golang?

How to catch an error in Go

connect: connection refused

I hope there are more human ways than through
strings.Contains(err.Error(), "connection refused")

https://play.golang.org/p/zgVJM9-Tjpe

Answer the question

In order to leave comments, you need to log in

1 answer(s)
V
Vladislav, 2020-06-20
@2ord

full expansion of the error:
https://play.golang.org/p/FXoa3wdGj8S
or simpler, just comparison with the error:
https://play.golang.org/p/KeTl1QAJBMs
you can find out what kind of structure is in the error using the debugger:
5eee5e686a011838001374.jpeg

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question