Using go, when I create a function with a return... and that function uses an if... else... condition w/ the return being passed under each, the compiler still throws an error 'missing return at end of function'? I can put a return at the end of the function, but it will never get to that point because of this condition. Is that expected, or could I be doing something different to prevent this outcome? Not that it matters... but I hate just having random returns at the bottom of functions that don't do anything other than satisfy this issue.
--
You received this message because you are subscribed to the Google Groups "golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
switch strings.Contains(targetDatabase.Driver, ConvertString("[!]sqlite[!]")) {
case true:
case false:
instead of
if strings.Contains(targetDatabase.Driver, ConvertString("[!]sqlite[!]")) {
} else {
}
Sorry guys, found the issue... and it's from my inexperience. The functions that is happening to are ones I used a switch condition (which I could've used an if condition on instead).
I used:switch strings.Contains(targetDatabase.Driver, ConvertString("[!]sqlite[!]")) {
case true:
case false:
instead of
if strings.Contains(targetDatabase.Driver, ConvertString("[!]sqlite[!]")) {
} else {
}
Of course the compiler won't always assume all possible outcomes of a switch to ensure it's being caught... and thus the problem. Wish I wouldn't have pre-emptively posted this now. My apologies...
On Saturday, January 14, 2017 at 3:31:32 PM UTC-6, Eric Brown wrote:Using go, when I create a function with a return... and that function uses an if... else... condition w/ the return being passed under each, the compiler still throws an error 'missing return at end of function'? I can put a return at the end of the function, but it will never get to that point because of this condition. Is that expected, or could I be doing something different to prevent this outcome? Not that it matters... but I hate just having random returns at the bottom of functions that don't do anything other than satisfy this issue.
--
You received this message because you are subscribed to the Google Groups "golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts...@googlegroups.com.
The former.