githublangsgo

package module
v1.0.2 Latest Latest
Warning

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

Go to latest
Published: Mar 22, 2025 License: MIT Imports: 4 Imported by: 2

README

github-langs-go

github-langs-go is a Go package that provides information about programming languages sourced from Github Linguist. It allows users to retrieve details such as color, extensions, and aliases for a given programming language.

Usage

  1. Installation:

    go get github.com/NDoolan360/github-langs-go
    
  2. Import in Your Code:

    import "github.com/NDoolan360/github-langs-go"
    
  3. Example Usage:

    func main() {
        language, err := githublangsgo.GetLanguage("go")
        if err != nil {
            fmt.Println("Error:", err)
            return
        }
    
        fmt.Println("Language Color:", language.Color)  // Language Color: #00ADD8
    }
    

Features

  • Retrieve information about programming languages.
  • Search by case-insensitive language name or by alias.

Contributing

If you find any issues or have suggestions for improvements, feel free to open an issue or submit a pull request.

License

This project is licensed under the MIT License.

Acknowledgments

Special thanks to the go-toml library for TOML parsing.

Author

Nathan Doolan

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrReadLanguagesFile  = errors.New("failed to read languages.toml")
	ErrUnmarshalLanguages = errors.New("failed to unmarshal languages.toml")
	ErrLanguageNotFound   = errors.New("language not found")
)

Functions

func GetAllLanguages

func GetAllLanguages() (map[string]Language, error)

Types

type Language

type Language struct {
	Type               string   `toml:"type"`
	Color              string   `toml:"color,omitempty"`
	Extensions         []string `toml:"extensions,omitempty"`
	TmScope            string   `toml:"tm_scope"`
	AceMode            string   `toml:"ace_mode"`
	LanguageID         int      `toml:"language_id"`
	Aliases            []string `toml:"aliases,omitempty"`
	CodemirrorMode     string   `toml:"codemirror_mode,omitempty"`
	CodemirrorMimeType string   `toml:"codemirror_mime_type,omitempty"`
	Interpreters       []string `toml:"interpreters,omitempty"`
	Group              string   `toml:"group,omitempty"`
	Filenames          []string `toml:"filenames,omitempty"`
	Wrap               bool     `toml:"wrap,omitempty"`
	FsName             string   `toml:"fs_name,omitempty"`
	Searchable         bool     `toml:"searchable,omitempty"`
}

func GetLanguage

func GetLanguage(languageName string) (Language, error)

Jump to

Keyboard shortcuts

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