github.com/switchupcb/yaegi@v0.10.2/_test/issue-735.go (about)

     1  package main
     2  
     3  import (
     4  	"fmt"
     5  	"strconv"
     6  )
     7  
     8  var optionsG map[string]string
     9  
    10  var roundG int = 30
    11  
    12  func strToInt(s string, defaultValue int) int {
    13  	n, err := strconv.ParseInt(s, 10, 0)
    14  	if err != nil {
    15  		return defaultValue
    16  	}
    17  	return int(n)
    18  }
    19  
    20  func main() {
    21  	optionsG := map[string]string{"round": "12", "b": "one"}
    22  	roundG = strToInt(optionsG["round"], 50)
    23  	fmt.Println(roundG)
    24  	fmt.Println(optionsG)
    25  }
    26  
    27  // Output:
    28  // 12
    29  // map[b:one round:12]