1
0
mirror of https://github.com/golang/go synced 2024-09-30 16:28:32 -06:00

internal/gopathwalk/walk: add missing function descriptions and renaming

Missing function descriptions are added. init is renamed setIgnoredDirs.

Change-Id: I56b5a7c3e4fcc27991b33aef16d506948ce4b36b
Reviewed-on: https://go-review.googlesource.com/c/tools/+/208358
Reviewed-by: Ian Cottrell <iancottrell@google.com>
This commit is contained in:
Arda Güçlü 2019-11-22 21:44:52 +03:00 committed by Ian Cottrell
parent bcb65d52f1
commit 99b39703f4

View File

@ -77,6 +77,7 @@ func WalkSkip(roots []Root, add func(root Root, dir string), skip func(root Root
} }
} }
// walkDir creates a walker and starts fastwalk with this walker.
func walkDir(root Root, add func(Root, string), skip func(root Root, dir string) bool, opts Options) { func walkDir(root Root, add func(Root, string), skip func(root Root, dir string) bool, opts Options) {
if _, err := os.Stat(root.Path); os.IsNotExist(err) { if _, err := os.Stat(root.Path); os.IsNotExist(err) {
if opts.Debug { if opts.Debug {
@ -114,7 +115,7 @@ type walker struct {
ignoredDirs []os.FileInfo // The ignored directories, loaded from .goimportsignore files. ignoredDirs []os.FileInfo // The ignored directories, loaded from .goimportsignore files.
} }
// init initializes the walker based on its Options. // init initializes the walker based on its Options
func (w *walker) init() { func (w *walker) init() {
var ignoredPaths []string var ignoredPaths []string
if w.root.Type == RootModuleCache { if w.root.Type == RootModuleCache {
@ -167,6 +168,7 @@ func (w *walker) getIgnoredDirs(path string) []string {
return ignoredDirs return ignoredDirs
} }
// shouldSkipDir reports whether the file should be skipped or not.
func (w *walker) shouldSkipDir(fi os.FileInfo, dir string) bool { func (w *walker) shouldSkipDir(fi os.FileInfo, dir string) bool {
for _, ignoredDir := range w.ignoredDirs { for _, ignoredDir := range w.ignoredDirs {
if os.SameFile(fi, ignoredDir) { if os.SameFile(fi, ignoredDir) {
@ -180,6 +182,7 @@ func (w *walker) shouldSkipDir(fi os.FileInfo, dir string) bool {
return false return false
} }
// walk walks through the given path.
func (w *walker) walk(path string, typ os.FileMode) error { func (w *walker) walk(path string, typ os.FileMode) error {
dir := filepath.Dir(path) dir := filepath.Dir(path)
if typ.IsRegular() { if typ.IsRegular() {