• Home
  • History
  • Annotate
Name Date Size #Lines LOC

..03-May-2022-

.travis.ymlH A D24-Jan-201954

LICENSEH A D24-Jan-20191.1 KiB

README.mdH A D24-Jan-20191.1 KiB

glob.goH A D24-Jan-20191.3 KiB

glob_test.goH A D24-Jan-20192.4 KiB

go.modH A D24-Jan-201935

README.md

1# String globbing in golang [![Build Status](https://travis-ci.org/ryanuber/go-glob.svg)](https://travis-ci.org/ryanuber/go-glob)
2
3`go-glob` is a single-function library implementing basic string glob support.
4
5Globs are an extremely user-friendly way of supporting string matching without
6requiring knowledge of regular expressions or Go's particular regex engine. Most
7people understand that if you put a `*` character somewhere in a string, it is
8treated as a wildcard. Surprisingly, this functionality isn't found in Go's
9standard library, except for `path.Match`, which is intended to be used while
10comparing paths (not arbitrary strings), and contains specialized logic for this
11use case. A better solution might be a POSIX basic (non-ERE) regular expression
12engine for Go, which doesn't exist currently.
13
14Example
15=======
16
17```
18package main
19
20import "github.com/ryanuber/go-glob"
21
22func main() {
23    glob.Glob("*World!", "Hello, World!") // true
24    glob.Glob("Hello,*", "Hello, World!") // true
25    glob.Glob("*ello,*", "Hello, World!") // true
26    glob.Glob("World!", "Hello, World!")  // false
27    glob.Glob("/home/*", "/home/ryanuber/.bashrc") // true
28}
29```
30