如何运行函数,直到返回期望值?

I want to run a function until it returns 0.

value, _ := FuncX()

if value != 0 {
                    value, _ := FuncX()
                  if(value != 0) {
                     value, _ := FuncX()
                      if(value != 0) ....
                  }
}

seems like a pretty ugly way to do it. Whats a possible better way?

for {
    value, _ := FuncX()
    if value == 0 {
        break
    }
}

You can use a loop like:

value, _ := FuncX()
for value == 0 {
    value, _ = FuncX() // note using the = not :=
}

A more complex loop header than others have offered, although having nothing in the loop body may trigger coder OCD.

for value,_ := FuncX(); value != 0; value,_ = FuncX() {
}

In fact, this is usually how I read files line by line in Go

// Assume we have some bufio.Reader named buf already created
for line,err := buf.ReadString('
'); err == nil; line,err = buf.ReadString('
') {
    // Do stuff with the line.
}

If you need line or err outside the loop you just predeclare them and replace the := with =.