qwalk

package module
v0.0.0-...-5832905 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 12, 2022 License: BSD-2-Clause Imports: 5 Imported by: 0

README

qwalk Go Reference Go CodeQL

Golang fastest directory walking method

Got the idea of creating this library based on @feyrob's godirlist repo: https://github.com/feyrob/godirlist

Examples

There are a few examples in the qwalk_test.go and qwalk_bench_test.go files if you want to see a very simplified version of what you can do with qwalk.

package main

import (
	"fmt"
	"runtime"
	
	"github.com/nikosgram/qwalk"
)

func main() {
	// print all no-directory items
	qwalk.Walk(
		[]string{"."},
		func(info qwalk.ItemInfo) bool {
			// print only from no-dir items
			if !info.Info.IsDir() {
				fmt.Println(info.Path)
			}

			// allow dir-listing on all directories
			return true
		},
		runtime.NumCPU(),
	)
}

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Walk

func Walk(
	targetDirAbsPaths []string,
	filterHandler FilterHandler,
	workerCount int,
)

func WalkWorker

func WalkWorker(
	workRequests chan string,
	bufferRequests chan string,
	filterHandler FilterHandler,
	incompleteRequestCount *int64,
	done chan struct{},
)

Types

type FilterHandler

type FilterHandler func(info ItemInfo) bool

type ItemInfo

type ItemInfo struct {
	Info os.FileInfo
	Path string // Absolute Path
}

func WalkSlice

func WalkSlice(
	targetDirAbsPaths []string,
	filterHandler FilterHandler,
	workerCount int,
) (results []ItemInfo)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL