R
R
Roman Rakzin2015-04-18 22:12:37
go
Roman Rakzin, 2015-04-18 22:12:37

How to handle an exception in golang?

Good afternoon, how to handle an exception in go?
There is a code Message.Send(ActiveClients[input].websocket, string(ans.Message))
And if instead of input we substitute either a string value or a non-existent numeric value, then the program crashes. How to process it?
Thanks

Answer the question

In order to leave comments, you need to log in

2 answer(s)
R
Roman Rakzin, 2015-04-18
@TwoRS

var a =ActiveClients[input].websocket
if a!=nil {Message.Send(ActiveClients[input].websocket, string(ans.Message))}

D
David Mzareulyan, 2015-04-18
@david_mz

Write with what message the program crashes.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question