Golang Case
func TestGolang(t *testing.T) {
fmt.Println(A()) // 0
fmt.Println(*B()) // 1
fmt.Println(C()) // 1
fmt.Println(D()) // 0
}
func A() int {
var result int
defer func() {
result++
}()
return result
}
func B() *int {
var result int
defer func() {
result++
}()
return &result
}
func C() (result int) {
defer func() {
result++
}()
return result
}
func D() int {
var result = 0
defer func() {
result++
}()
return result
}