language

package
v0.7.0 Latest Latest
Warning

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

Go to latest
Published: Jun 2, 2026 License: GPL-2.0, GPL-2.0-only Imports: 10 Imported by: 0

Documentation

Overview

Package language provides automatic programming language detection for source code. It uses go-enry to accurately identify languages in target directories.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Detector

type Detector interface {
	// Detect analyzes the target directory and returns detected languages.
	// Returns language names in lowercase (e.g., "java", "python", "go").
	//
	// The detector recursively scans all files in the target path,
	// excluding directories based on configured skip patterns.
	// Skip patterns follow gitignore syntax and can be configured via scanoss.json.
	//
	// Parameters:
	//   - targetPath: Absolute or relative path to the directory to analyze
	//
	// Returns:
	//   - []string: Slice of detected language names (lowercase, deduplicated)
	//   - error: Error if path doesn't exist or cannot be read
	Detect(targetPath string) ([]string, error)
}

Detector analyzes source code to automatically detect programming languages present in the target directory.

type EnryDetector

type EnryDetector struct {
	// contains filtered or unexported fields
}

EnryDetector implements the Detector interface using GitHub's go-enry library. It provides accurate language detection based on file extensions, contents, and linguistic analysis.

func NewEnryDetector

func NewEnryDetector(matcher skip.SkipMatcher) *EnryDetector

NewEnryDetector creates a new EnryDetector with a custom SkipMatcher.

func (*EnryDetector) Detect

func (d *EnryDetector) Detect(targetPath string) ([]string, error)

Detect analyzes the target directory and returns all detected programming languages. It recursively scans all files, uses go-enry for detection, and returns unique language names in lowercase.

Jump to

Keyboard shortcuts

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