Esempio n. 1
0
func (a *AdminBaseController) setA_B() (key_a, key_b int) {
	key_a = lib.RandomInt(5, 49)
	a.SetSession(KEY_A, key_a)
	a.Data["a"] = key_a
	key_b = lib.RandomInt(5, 50)
	a.SetSession(KEY_B, key_b)
	a.Data["b"] = key_b
	return
}
Esempio n. 2
0
func (a *AdminBaseController) verifySecret() {
	m := make(map[string]int)
	m["a"] = lib.RandomInt(5, 49)
	a.SetSession("a", m["a"])
	m["b"] = lib.RandomInt(5, 50)
	a.SetSession("b", m["b"])

	a.WriteJSON(http.StatusOK, m)
}
Esempio n. 3
0
File: main.go Progetto: ckeyer/tools
var (
	rtype string

	start = flag.Int("start", 0, "set start of rand number")
	end   = flag.Int("end", 100, "set end of rand number")

	randMap = map[string]randHandle{
		"s": func(l int) string {
			fmt.Println("...")
			return lib.RandomString(l)
		},
		"n": func(l int) string {
			ns := make([]string, 0, l)
			for i := 0; i < l; i++ {
				ns = append(ns, fmt.Sprint(lib.RandomInt(*start, *end)))
			}
			return strings.Join(ns, ", ")
		},
	}
)

type randHandle func(l int) string

func init() {
	flag.Parse()
	args := flag.Args()
	if len(args) != 2 {
		fmt.Println("error args length...")
		os.Exit(1)
	}