sloc

package module
v0.0.0-...-ba0cecc Latest Latest
Warning

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

Go to latest
Published: Jan 22, 2017 License: MIT Imports: 4 Imported by: 0

README

sloc

GoDoc

A sloc counter.

cmd

You can install a sloc binary from the cmd directory. It's a small CLI utility that counts the SLOC in a dirctory.

Documentation

Overview

Package sloc provides function for counting source lines of code.

Index

Constants

This section is empty.

Variables

View Source
var CStyleComments = CommentStyle{
	LinePre("\\/\\/"),
	[]string{LinePre("\\/\\*"), "\\*\\/"},
}
View Source
var Languages = []*Language{
	&Language{"C", []string{"c", "h"}, &CStyleComments},
	&Language{"C++", []string{"cpp", "cc", "hh", "hpp"}, &CStyleComments},
	&Language{"Java", []string{"java"}, &CStyleComments},
	&Language{"JavaScript", []string{"js"}, &CStyleComments},
	&Language{"Go", []string{"go"}, &CStyleComments},
	&Language{"Ruby", []string{"rb"}, &CommentStyle{LinePre("#"), []string{"^=begin", "^=end"}}},
	&Language{"Python", []string{"py"}, &CommentStyle{LinePre("#"), []string{"^=begin", "^=end"}}},
	&Language{"Lua", []string{"lua"}, &CommentStyle{LinePre("--"), []string{"--[[", "]]--"}}},
	&Language{"Lisp", []string{"el", "lsp", "scm"}, &CommentStyle{LinePre(";"), nil}},
	&Language{"Shell", []string{"sh"}, &CommentStyle{LinePre("#"), nil}},
}

Functions

func CountLines

func CountLines(i io.Reader, l *Language) int

Counts the lines of code from a Reader stream.

func LinePre

func LinePre(match string) string

Define the line prefix (ignoring whitespace)

Types

type CommentStyle

type CommentStyle struct {
	SingleComment string
	MultiComment  []string
}

A CommentStyle for a Language describing how to match a comment so it can be ignored in the sloc count.

type Language

type Language struct {
	Name         string
	Ext          []string
	CommentStyle *CommentStyle
}

A Language is used for matching an extension and describing how to name a languge and match a comment

func GetLanguage

func GetLanguage(ext string) *Language

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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