glob

package
v0.3.4 Latest Latest
Warning

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

Go to latest
Published: May 8, 2020 License: MPL-2.0, MIT Imports: 1 Imported by: 0

README

String globbing in Go

GoDoc

This package adds support for globs in Go.

It simply converts glob expressions to regexps. I try to follow the standard defined here.

Example

package main

import "github.com/zyedidia/glob"

func main() {
    glob, err := glob.Compile("{*.go,*.c}")
    if err != nil {
        // Error
    }

    glob.Match([]byte("test.c"))   // true
    glob.Match([]byte("hello.go")) // true
    glob.Match([]byte("test.d"))   // false
}

You can call all the same functions on a glob that you can call on a regexp.

Documentation

Overview

Package glob provides objects for matching strings with globs

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Glob

type Glob struct {
	*regexp.Regexp
}

Glob is a wrapper of *regexp.Regexp. It should contain a glob expression compiled into a regular expression.

func Compile

func Compile(pattern string) (*Glob, error)

Compile a takes a glob expression as a string and transforms it into a *Glob object (which is really just a regular expression) Compile also returns a possible error.

Jump to

Keyboard shortcuts

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