glob

package
v0.0.0-...-c37dd20 Latest Latest
Warning

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

Go to latest
Published: Dec 7, 2022 License: MIT Imports: 2 Imported by: 0

Documentation

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Dir

type Dir struct {
	ExcludeSubdirs bool
	Subdirs        map[DirName]Dir

	ExcludeInterfaces    bool
	InterfacesExceptions map[string]struct{}
}

type DirName

type DirName = string

type Glob

type Glob struct {
	RootDir *Dir
}
Example (ExcludeSome)
glob, err := NewGlob([]string{
	"!proto",
	"proto@A,B",
	"proto/good",
	"!proto/good@C",
})
fmt.Println("Glob create error:", err)
fmt.Println("Glob tree:")
printDirs(glob.RootDir, "  ")
Output:

Glob create error: <nil>
Glob tree:
  ExcludeInterfaces: false
  InterfacesExceptions: []
  ExcludeSubdirs: false
  Subdirs:
  ├─Name: proto
  │ ExcludeInterfaces: true
  │ InterfacesExceptions: [A, B]
  │ ExcludeSubdirs: true
  │ Subdirs:
  │ ├─Name: good
  │ │ ExcludeInterfaces: false
  │ │ InterfacesExceptions: [C]
  │ │ ExcludeSubdirs: false
  │ │ Subdirs:
Example (IncludeSome)
glob, err := NewGlob([]string{
	"!.",
	"internal/service@A,B",
	"internal/server",
	"!internal/server@BadInterface",
})
fmt.Println("Glob create error:", err)
fmt.Println("Glob tree:")
printDirs(glob.RootDir, "  ")
Output:

Glob create error: <nil>
Glob tree:
  ExcludeInterfaces: true
  InterfacesExceptions: []
  ExcludeSubdirs: true
  Subdirs:
  ├─Name: internal
  │ ExcludeInterfaces: true
  │ InterfacesExceptions: []
  │ ExcludeSubdirs: true
  │ Subdirs:
  │ ├─Name: server
  │ │ ExcludeInterfaces: false
  │ │ InterfacesExceptions: [BadInterface]
  │ │ ExcludeSubdirs: false
  │ │ Subdirs:
  │ ├─Name: service
  │ │ ExcludeInterfaces: true
  │ │ InterfacesExceptions: [A, B]
  │ │ ExcludeSubdirs: true
  │ │ Subdirs:
Example (RevertingRule)
glob, err := NewGlob([]string{
	"!abc@A,B,C,D",
	"abc@C,B",
})
fmt.Println("Glob create error:", err)
fmt.Println("Glob tree:")
printDirs(glob.RootDir, "  ")
Output:

Glob create error: <nil>
Glob tree:
  ExcludeInterfaces: false
  InterfacesExceptions: []
  ExcludeSubdirs: false
  Subdirs:
  ├─Name: abc
  │ ExcludeInterfaces: false
  │ InterfacesExceptions: [A, D]
  │ ExcludeSubdirs: false
  │ Subdirs:
Example (Root)
_, err := NewGlob([]string{
	"@A",
})
fmt.Println("Glob create error:", err)

_, err = NewGlob([]string{
	"!",
})
fmt.Println("Glob create error:", err)

glob, err := NewGlob([]string{
	"!.",
	".@A,B",
})
fmt.Println("Glob create error:", err)
fmt.Println("Glob tree:")
printDirs(glob.RootDir, "  ")
Output:

Glob create error: rule 1: use . for root dir
Glob create error: rule 1: use . for root dir
Glob create error: <nil>
Glob tree:
  ExcludeInterfaces: true
  InterfacesExceptions: [A, B]
  ExcludeSubdirs: true
  Subdirs:
Example (Simple)
glob, err := NewGlob([]string{})
fmt.Println("Glob create error:", err)
fmt.Println("Glob tree:")
printDirs(glob.RootDir, "  ")
Output:

Glob create error: <nil>
Glob tree:
  ExcludeInterfaces: false
  InterfacesExceptions: []
  ExcludeSubdirs: false
  Subdirs:
Example (TooManyAtSigns)
_, err := NewGlob([]string{
	"abc@kj@ie",
})
fmt.Println("Glob create error:", err)
Output:

Glob create error: rule 1: only one @ allowed

func NewGlob

func NewGlob(rules []string) (*Glob, error)

Jump to

Keyboard shortcuts

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