R
R
Roman Rakzin2015-07-14 18:14:34
go
Roman Rakzin, 2015-07-14 18:14:34

How to interrupt code execution in Golang?

How to interrupt code execution in Golang? (similar to exit()/die() in php)
There is
func Index(w http.ResponseWriter, r *http.Request) {
parametr=0
if parametr!="1" {
fmt.Fprintln(w, "Parameter=1" )
}
fmt.Fprintln(w, "text after validation") //I don't want to display this if parametr!="1"
}
//Need, if the parameter is not 1, then exit the function. (but not the application at all )
Of course, you can put else , but then do wrappers everywhere? or you can somehow exit the function

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
Damir Makhmutov, 2015-07-14
@TwoRS

os.Exit()

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question