watch

package
v0.0.178 Latest Latest
Warning

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

Go to latest
Published: Oct 15, 2026 License: MIT Imports: 12 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Example (MatchesIncludeExclude)

Example_matchesIncludeExclude demonstrates pattern matching

// Test various file patterns
files := []string{
	"main.go",
	"test.txt",
	"debug.log",
	".gitignore",
	"temp.tmp",
}

include := []string{"*.go", "*.txt"}
exclude := []string{"*.log", "*.tmp"}

fmt.Println("File matching results:")
for _, file := range files {
	result := matchesIncludeExclude(file, include, exclude)
	fmt.Printf("  %s: %v\n", file, result)
}
Output:
File matching results:
  main.go: true
  test.txt: true
  debug.log: false
  .gitignore: false
  temp.tmp: false
Example (ShouldIgnoreDirectory)

Example_shouldIgnoreDirectory demonstrates directory filtering

directories := []string{
	"/path/to/src",
	"/path/to/.git",
	"/path/to/node_modules",
	"/path/to/build",
	"/path/to/normal",
}

fmt.Println("Directory filtering results:")
for _, dir := range directories {
	result := shouldIgnoreDirectory(dir)
	fmt.Printf("  %s: ignored=%v\n", dir, result)
}
Output:
Directory filtering results:
  /path/to/src: ignored=false
  /path/to/.git: ignored=true
  /path/to/node_modules: ignored=true
  /path/to/build: ignored=true
  /path/to/normal: ignored=false

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

func Handle

func Handle(args []string) error

Types

type WatchCallback

type WatchCallback func(changedFiles []string)

WatchCallback is called when files change

type WatchOptions

type WatchOptions struct {
	Dir      string
	Throttle time.Duration
	Include  []string
	Exclude  []string
}

WatchOptions contains configuration for the file watcher

Example

ExampleWatchOptions demonstrates how to create WatchOptions

// Create default options
defaultOptions := WatchOptions{
	Dir:      "",
	Throttle: 1 * time.Second,
	Include:  []string{},
	Exclude:  []string{},
}

// Create custom options
customOptions := WatchOptions{
	Dir:      "/tmp",
	Throttle: 500 * time.Millisecond,
	Include:  []string{"*.txt", "*.go"},
	Exclude:  []string{"*.log", "*.tmp"},
}

fmt.Printf("Default options: %+v\n", defaultOptions)
fmt.Printf("Custom options: %+v\n", customOptions)
Output:
Default options: {Dir: Throttle:1s Include:[] Exclude:[]}
Custom options: {Dir:/tmp Throttle:500ms Include:[*.txt *.go] Exclude:[*.log *.tmp]}

Jump to

Keyboard shortcuts

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