Looks nice. I just want to point out two places that are not
quite as idiomatic Go as they could be. First, none of the parens
you have on if conditions are necessary, not even the ones
in the branches of the && expression. Running gofmt -w fibonacci.go
will remove the top-level ones for you; you'll have to remove the
ones in the && yourself. Second, the sequence of if statements
checking various conditions can be written as a switch:
switch {
//Make sure the conversion went correctly, otherwise return failure.
case err != nil:
return -1, "Invalid argument. Argument must be an integer.\n"
//Since this implementation is limited, make sure the user can't go
//beyond the program's limits.
case goal > 46:
return -1, "This program only calculates up to the 46th Fibonacci number.\n"
//Check the lower bound as well.
case goal < 1:
return -1, "Invalid range. Number must be >= 1.\n"
}
Hope you're having fun writing Go programs.
Russ