mirror of
https://github.com/go-delve/delve.git
synced 2025-10-27 03:56:24 +08:00
Variables normally become visible on the line after the one they are defined at, because on their definition line they will not be initialized. This is a problem for variables captured by closures because they get the closure function's first line as the declaration line. Make variables captured by closures visible on their declaration line and load their value from the closure struct if they are unreadable. Fixes #4000
15 lines
185 B
Go
15 lines
185 B
Go
package main
|
|
|
|
import "fmt"
|
|
|
|
func main() {
|
|
var test = "a string"
|
|
var f = func() {
|
|
test = "another string"
|
|
fmt.Println("test", test)
|
|
}
|
|
fmt.Println(test)
|
|
f()
|
|
fmt.Println(test)
|
|
}
|