File: util.go

package info (click to toggle)
golang-github-jeremija-gosubmit 0.2.8-1~bpo12%2B1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm-backports
  • size: 176 kB
  • sloc: makefile: 7
file content (32 lines) | stat: -rw-r--r-- 562 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
package gosubmit

import (
	"math/rand"
	"strconv"
	"strings"
	"time"
)

func atoi(str string) int {
	value, _ := strconv.Atoi(str)
	return value
}

func itoa(value int) string {
	return strconv.Itoa(value)
}

const letters = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"

var randomSource = rand.NewSource(time.Now().UnixNano())

func randomString(size int) string {
	lettersCount := len(letters)
	var b strings.Builder
	b.Grow(size)
	for i := 0; i < size; i++ {
		index := rand.Intn(lettersCount)
		b.WriteByte(letters[index])
	}
	return b.String()
}