package main import ( "flag" "fmt" "math/rand" "time" ) func main() { var surfaces, throws int rand.Seed(time.Now().Unix()) flag.IntVar(&surfaces, "s", 20, "Specify amount of die surfaces") flag.IntVar(&throws, "t", 1, "Specify dice throws") flag.Parse() Cast(surfaces, throws) } func Cast(dieSurfaces, castAmount int) { var ( casts []int cast, total int ) for i := 0; i < castAmount; i++ { cast = rand.Intn(dieSurfaces) + 1 casts = append(casts, cast) total += cast } if castAmount > 1 { fmt.Println(casts) } fmt.Println(total) }