MCPcopy Create free account
hub / github.com/arnauddri/algorithms / GetArrayOfSize

Function GetArrayOfSize

algorithms/sorting/utils/utils.go:11–30  ·  view source on GitHub ↗
(n int)

Source from the content-addressed store, hash-verified

9)
10
11func GetArrayOfSize(n int) []int {
12 p, err := build.Default.Import("github.com/arnauddri/algorithms/algorithms/sorting/utils", "", build.FindOnly)
13
14 if err != nil {
15 // handle error
16 }
17 fname := filepath.Join(p.Dir, "IntegerArray.txt")
18 f, _ := os.Open(fname)
19 defer f.Close()
20
21 numbers := make([]int, 0)
22 scanner := bufio.NewScanner(f)
23
24 for scanner.Scan() {
25 s, _ := strconv.Atoi(scanner.Text())
26 numbers = append(numbers, s)
27 }
28
29 return numbers[0:n]
30}

Callers 1

TestReadFunction · 0.85

Calls

no outgoing calls

Tested by 1

TestReadFunction · 0.68