I'm having trouble returning a function's expected return statement from within an if statement in golang.
I have provided the code below:
package main
import (
"fmt"
)
func random() string {
var x = "return"
if x == "return" {
return x
}
}
func main() {
fmt.Println(random())
}
Shouldn't the main function print out the string value returned by the random function?All i get is
go.go:13: missing return at end of function
Does anybody have a clue how to make this happen?