languages

package
v0.0.40 Latest Latest
Warning

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

Go to latest
Published: Sep 2, 2026 License: Apache-2.0 Imports: 6 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FormatBreakdown

func FormatBreakdown(breakdown []LanguageBreakdown) string

FormatBreakdown formats a language breakdown slice into a human-readable string. Example output: "Go: 12345 bytes (67%) | Python: 5678 bytes (33%)"

func GetHeadCommit

func GetHeadCommit(repoPath string) (string, error)

GetHeadCommit returns the HEAD commit SHA for a git repository.

func LanguageForFile

func LanguageForFile(filePath string) string

LanguageForFile returns the language name for a given file path, or empty string if the file type is not recognized. It checks exact filename first, then falls back to extension matching.

Types

type LanguageBreakdown

type LanguageBreakdown struct {
	Name    string `json:"name"`
	Size    int64  `json:"size"`
	Percent int    `json:"percent"` // floor of (size/total * 100)
}

LanguageBreakdown represents one language's share of a repository.

func DetectLanguages

func DetectLanguages(repoPath string) ([]LanguageBreakdown, error)

DetectLanguages analyzes a git repository at the given path and returns a sorted list of language breakdowns (most bytes first). It uses `git ls-tree -r -l HEAD` to enumerate tracked files with their sizes.

func ParseLsTree

func ParseLsTree(output string) ([]LanguageBreakdown, error)

ParseLsTree parses the output of `git ls-tree -r -l HEAD` and returns language breakdowns. Exported for testability.

Each line has the format:

<mode> <type> <hash> <size>\t<path>

Example:

100644 blob abc123  1234\tmain.go

Jump to

Keyboard shortcuts

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