package open import ( "context" randomapi "service.xpcool.com/api/open/v1/tools/random" "service.xpcool.com/common/tools/random" ) // Random generates a random string of the requested type and length. func (c *Controller) Random(ctx context.Context, req *randomapi.RandomReq) (res *randomapi.RandomRes, err error) { var value string switch req.Type { case "digits": value = random.Digits(req.Length) case "letters": value = random.Letters(req.Length) default: value = random.String(req.Length) } return &randomapi.RandomRes{Value: value}, nil }