This file is indexed.

/usr/share/gocode/src/github.com/smartystreets/goconvey/web/server/watcher/walk_step.go is in golang-github-smartystreets-goconvey-dev 1.5.0-1.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

 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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
package watcher

import (
	"os"
	"path/filepath"
	"strings"

	"github.com/smartystreets/goconvey/web/server/contract"
)

type walkStep struct {
	root    string
	path    string
	folder  string
	info    os.FileInfo
	watcher contract.Watcher
}

func (self *walkStep) IncludeIn(walked map[string]bool) {
	walked[self.folder] = true
}

func (self *walkStep) Sum() int64 {
	if self.watcher.IsIgnored(self.folder) || self.isIrrelevant() {
		return 0
	}

	if self.info.IsDir() {
		return 1
	}
	return self.info.Size() + self.info.ModTime().Unix()
}

func (self *walkStep) isIrrelevant() bool {
	return !self.isWatchedFolder() && !self.isWatchedFile()
}

func (self *walkStep) isWatchedFolder() bool {
	return strings.HasPrefix(self.path, self.root) &&
		self.info.IsDir()
}

func (self *walkStep) isWatchedFile() bool {
	return self.watcher.IsWatched(self.folder) &&
		filepath.Ext(self.path) == ".go" &&
		!strings.HasPrefix(filepath.Base(self.path), ".")
}

func newWalkStep(root, path string, info os.FileInfo, watcher contract.Watcher) *walkStep {
	self := &walkStep{}
	self.root = root
	self.path = path
	self.info = info
	self.folder = deriveFolderName(path, info)
	self.watcher = watcher
	return self
}

func deriveFolderName(path string, info os.FileInfo) string {
	if info.IsDir() {
		return path
	} else {
		return filepath.Dir(path)
	}
}