Back to

Package detect

Latest Go to latest

The latest major version is .

Published: Jan 6, 2016 | License: MPL-2.0 | Module:


func App

func App(dir string, c *Config) (string, error)

App will detect the application type for the given directory.

type Config

type Config struct {
	Detectors []*Detector

Config is the format of the configuration files

func Parse

func Parse(r io.Reader) (*Config, error)

Parse parses the detector config from the given io.Reader.

Due to current internal limitations, the entire contents of the io.Reader will be copied into memory first before parsing.

func ParseDir

func ParseDir(path string) (*Config, error)

ParseDir parses all the files ending in ".hcl" in a directory, sorted alphabetically.

func ParseFile

func ParseFile(path string) (*Config, error)

ParseFile parses the given path as a single detector config.

func (*Config) Merge

func (c *Config) Merge(c2 *Config) error

Merge merges another config into this one. This will modify this Config object. Detectors in c2 are tried after detectors in this Config. Conflicts are ignored as lower priority detectors, meaning that if two detectors are for type "go", both will be tried.

type Detector

type Detector struct {
	// Type is the type that will match if this detector matches
	Type string

	// File is a list of file globs to look for. If any are found, it is
	// a match.
	File []string

	// Contents is a content matcher. The key is a filename and the
	// path is the file contents regular expression.
	Contents map[string]string

	// Priority is used to break ties when two detectors conflict.
	// The detector with the higher (larger number) priority wins.
	// This defaults to 0. Negative numbers can be used to lower
	// priority and positive numbers can be used to increase it.
	// In most cases, a priority never needs to be set. Please set this
	// with care.
	Priority int

Detector is something that detects a single type.

func (*Detector) Detect

func (d *Detector) Detect(dir string) (bool, error)

Detect will return true if this detector matches within the given directory.

func (*Detector) GoString

func (d *Detector) GoString() string

type DetectorList

type DetectorList []*Detector

DetectorList is a sortable slice of Detectors, and implements sort.Interface.

func (DetectorList) Len

func (l DetectorList) Len() int

func (DetectorList) Less

func (l DetectorList) Less(i, j int) bool

func (DetectorList) Swap

func (l DetectorList) Swap(i, j int)

Package Files

Documentation was rendered with GOOS=linux and GOARCH=amd64.

Jump to identifier

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to identifier