When you write "if x, ok := ... { }" that declares a new variable "x"
(and a new variable "ok") that are only visible in the if statement.
The "x" declared in the if statement shadows the "x" declared in "var
x int". That is, there are two different variables named "x" here.
The one declared in the "if" statement is not used.
It looks like you may want to write something like
var x int
var ok bool
if x, ok = MyFunc(); !ok {
fmt.Println("Err")
}
fmt.Println(x)
Note the use of "=" rather than ":=" in the if statement.
Ian