In all situations where the results are set directly to the frame, and not using a value helper, the right level of indirections must be applied, otherwise we may end-up writing in the wrong frame (the local one, instead of a caller or global). Fixes #735.
30 lines
444 B
Go
30 lines
444 B
Go
package main
|
|
|
|
import (
|
|
"fmt"
|
|
"strconv"
|
|
)
|
|
|
|
var optionsG map[string]string
|
|
|
|
var roundG int = 30
|
|
|
|
func strToInt(s string, defaultValue int) int {
|
|
n, err := strconv.ParseInt(s, 10, 0)
|
|
if err != nil {
|
|
return defaultValue
|
|
}
|
|
return int(n)
|
|
}
|
|
|
|
func main() {
|
|
optionsG := map[string]string{"round": "12", "b": "one"}
|
|
roundG = strToInt(optionsG["round"], 50)
|
|
fmt.Println(roundG)
|
|
fmt.Println(optionsG)
|
|
}
|
|
|
|
// Output:
|
|
// 12
|
|
// map[b:one round:12]
|