aboutsummaryrefslogtreecommitdiff
path: root/internal/scanner/scanner.go
blob: ca601ba71e75682c186f26f3e841193200980122 (plain)
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
package scanner

import "context"

type Scanner struct {
	roots []string
}

func New(roots []string) *Scanner {
	return &Scanner{
		roots: roots,
	}
}

// Scan walks every configured root and returns the discovered files.
//
// The returned slice is not guaranteed to be sorted.
func (s *Scanner) Scan(ctx context.Context) ([]File, error) {
	var files []File

	for _, root := range s.roots {
		discovered, err := s.walk(ctx, root)
		if err != nil {
			return nil, err
		}

		files = append(files, discovered...)
	}

	return nil, nil
}