"init(i int)" is invalid
tebeka opened this issue · comments
Miki Tebeka commented
In "Error Handling" there's the following example:
func init(i int) {
...
//This is just to deliberately crash the function.
if i < 2 {
fmt.Printf("Var %d - initialized\n", i)
} else {
//This was never supposed to happen, so we'll terminate our program.
log.Fatal("Init failure - Terminating.")
}
}
This code won't compile, the error is:
func init must have no arguments and no return values
Rename it to initialize
?
PauloASilva commented
Hi @tebeka,
You're right, because init
is a reserved function.
I do agree renaming it initialize
.
Would you like to open a Pull Request? I would love to accept it.
BTW, main
function is missing the }
: can you please fix that as well? ;)
Cheers,
Paulo A. Silva
Miki Tebeka commented
Done in #80