language

package
v1.0.5 Latest Latest
Warning

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

Go to latest
Published: Jun 4, 2025 License: MIT Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var FileExtensions = map[string]string{}/* 247 elements not displayed */

FileExtensions is the map of file extensions.

Functions

func GetAllFiles

func GetAllFiles(paths []string, languages *DefinedLanguages, opts *option.GClocOptions) (map[string]*Language, error)

GetAllFiles return all the files to be analyzed in paths.

func GetFileType

func GetFileType(path string, opts *option.GClocOptions) (ext string, ok bool)

GetFileType get the file type from the file path.

func GetFileTypeByShebang

func GetFileTypeByShebang(path string) (shebangLang string, ok bool)

GetFileTypeByShebang returns the language from the shebang line.

func GetShebang

func GetShebang(line string) (shebangLang string, ok bool)

GetShebang returns the language from the shebang line.

Types

type DefinedLanguages

type DefinedLanguages struct {
	Langs map[string]*Language
}

DefinedLanguages is the struct for the defined languages.

func NewDefinedLanguages

func NewDefinedLanguages() *DefinedLanguages

func (*DefinedLanguages) GetFormattedString

func (l *DefinedLanguages) GetFormattedString() string

GetFormattedString return DefinedLanguages as a human-readable string.

type GClocLanguage

type GClocLanguage struct {
	Name      string `xml:"name,attr" json:"name,omitempty"`   // Name of the language
	FileCount uint32 `xml:"file_count,attr" json:"file_count"` // Number of files
	Codes     uint32 `xml:"codes,attr" json:"codes"`           // Number of lines of code
	Comments  uint32 `xml:"comments,attr" json:"comments"`     // Number of lines of comments
	Blanks    uint32 `xml:"blanks,attr" json:"blanks"`         // Number of blank lines
}

GClocLanguage is provided for xml-cloc and json format.

type Language

type Language struct {
	Name              string
	LineComments      []string
	RegexLineComments []*regexp.Regexp
	MultipleLines     [][]string
	Files             []string
	Codes             uint32
	Comments          uint32
	Blanks            uint32
	Total             uint32
}

Language is the struct for the language.

func NewLanguage

func NewLanguage(name string, lineComments []string, multipleLines [][]string) *Language

NewLanguage creates a new language.

func (*Language) AddRegexLineComments

func (l *Language) AddRegexLineComments(regexLineComments []string) *Language

AddRegexLineComments adds the regex line comments.

type Languages

type Languages []Language

Languages is the slice of Language.

func (Languages) Len

func (ls Languages) Len() int

Len returns the length of the languages.

func (Languages) SortByBlanks

func (ls Languages) SortByBlanks()

SortByBlanks sorts the languages by blanks. (DESC)

func (Languages) SortByCodes

func (ls Languages) SortByCodes()

SortByCodes sorts the languages by codes. (DESC)

func (Languages) SortByComments

func (ls Languages) SortByComments()

SortByComments sorts the languages by comments. (DESC)

func (Languages) SortByFiles

func (ls Languages) SortByFiles()

SortByFiles sorts the languages by files. (DESC)

func (Languages) SortByName

func (ls Languages) SortByName()

SortByName sorts the languages by name. (ASC)

Jump to

Keyboard shortcuts

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