Documentation
¶
Index ¶
Constants ¶
const Separator = "/"
Variables ¶
This section is empty.
Functions ¶
func RegisterLanguage ¶
func RegisterLanguage(lang Language)
Types ¶
type Config ¶
type Config struct {
// Out is a destination to write JSON output to during Extract.
Out io.Writer
// Num is the maximal number of goroutines when extracting imports.
// Zero value means use NumCPU.
Num int
// MaxSize is the maximal size of files in bytes that will be parsed.
// For files larger than this, only a sample of this size will be used for language detection.
// Library may use the sample to try extracting imports, or may return an empty list of imports.
MaxSize int64
// SymLinks is option that allows traversal over sym-links, be aware of potentials loops
// if false - all symlinks will be skipped
SymLinks bool
}
type Extractor ¶
type Extractor struct {
// contains filtered or unexported fields
}
func NewExtractor ¶
NewExtractor creates an extractor with a given configuration. See Config for more details.
func (*Extractor) Extract ¶
Extract imports recursively from a given directory. The root is a root of the project's repository and rel is the relative path inside it that will be processed. Two paths exists to allow the library to potentially parse dependency manifest files that are usually located in the root of the project.
func (*Extractor) ExtractFrom ¶
ExtractFrom extracts imports from a given file content, assuming it had a given path.
The path is used for language detection only. It won't access any files locally and won't fetch dependency manifests as Extract may do.
type File ¶
type File struct {
Path string `json:"file"`
Lang string `json:"lang,omitempty"`
Imports []string `json:"imports,omitempty"`
}
func Extract ¶
Extract imports from a given file content, assuming it had a given path.
The path is used for language detection only. It won't access any files locally and won't fetch dependency manifests as Extract may do.
The function does no sampling for the file, it means if the file size is large, it may take a lot of time to parse it or even detect the language. Instead, passing a part of the file may be an option.