Skip to content

idelchi/go-match

Repository files navigation

go-match

Go Reference Go Report Card Build Status License: MIT

go-match is a simple command-line utility that filters a list of paths based on include and exclude globstar patterns.

The program takes a list of paths as input and outputs a JSON array of paths that match the include patterns and don't match the exclude patterns.

Installation

From source

go install github.com/idelchi/go-match/@latest

From installation script

curl -sSL https://raw.githubusercontent.com/idelchi/go-match/refs/heads/main/install.sh | sh -s -- -d ~/.local/bin

Usage

go-match [flags] [paths...]

Global Flags and Environment Variables

Flag Environment Variable Description Default
--include GO_MATCH_INCLUDE Include patterns (can be used multiple times) -
--exclude GO_MATCH_EXCLUDE Exclude patterns (can be used multiple times) -
-h, --help - Help for go-match -
-v, --version - Version for go-match -

Examples

# Filter Go files excluding a specific directory
go-match --include "**/*.go" --exclude "path/to/another/*" \
    path/to/dir1 \
    path/to/dir2 \
    path/to/file.go \
    path/to/another/file.go

# Output:
["path/to/file.go"]

Pattern Syntax

  • Use globstar patterns (**) to match multiple directory levels
  • Use single asterisk (*) to match within a single directory level
  • Patterns are case-sensitive
  • Multiple include/exclude patterns can be specified

For detailed help:

go-match --help

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Packages

No packages published