This program returns:
package main
import (
"flag"
"fmt"
)
func main() {
num_agents := flag.Int("a", 10, "number of agents")
flag.Parse();
fmt.Printf("%#v",num_agents)
}
Outputs
(*int)(0x18600110)`
However that is not what I want... What I want is the integer.
So according to the documentation seems I should use flag.IntVar(&pointer_to_variable_integer)
package main
import (
"flag"
"fmt"
)
func main() {
var num_agents int
flag.IntVar(&num_agents,"a", 10, "number of agents")
flag.Parse();
fmt.Printf("%#v",num_agents)
}
However that doesn't seem right... Because I need to write 2 lines of code when 1 should do. somehow it seems to me that
num_agents := flags.Int("a", 10, "number of agents")
Should return an int instead of *int.? Or maybe there is an easy way to cast from *int to int ??