Skip to content

Commit

Permalink
add description for exported var, type, etc.
Browse files Browse the repository at this point in the history
  • Loading branch information
Hideo Hattori committed Feb 13, 2020
1 parent 6acb1b3 commit 54204ce
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
5 changes: 5 additions & 0 deletions cmd/gocloc/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,10 @@ import (
flags "github.com/jessevdk/go-flags"
)

// Version is version string for gocloc command
var Version string

// GitCommit is git commit hash string for gocloc command
var GitCommit string

// OutputTypeDefault is cloc's text output format for --output-type option
Expand All @@ -36,6 +39,8 @@ const defaultOutputSeparator string = "-----------------------------------------

var rowLen = 79

// CmdOptions is gocloc command options.
// It is necessary to use notation that follows go-flags.
type CmdOptions struct {
Byfile bool `long:"by-file" description:"report results for every encountered source file"`
SortTag string `long:"sort" default:"code" description:"sort based on a certain column"`
Expand Down
4 changes: 4 additions & 0 deletions file.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (
"unicode"
)

// ClocFile is collecting to line count result
type ClocFile struct {
Code int32 `xml:"code,attr" json:"code"`
Comments int32 `xml:"comment,attr" json:"comment"`
Expand All @@ -17,6 +18,7 @@ type ClocFile struct {
Lang string `xml:"language,attr" json"language"`
}

// ClocFiles is gocloc result set
type ClocFiles []ClocFile

func (cf ClocFiles) Len() int {
Expand All @@ -32,6 +34,7 @@ func (cf ClocFiles) Less(i, j int) bool {
return cf[i].Code > cf[j].Code
}

// AnalyzeFile is analyzing file, this function calls AnalyzeReader() inside.
func AnalyzeFile(filename string, language *Language, opts *ClocOptions) *ClocFile {
fp, err := os.Open(filename)
if err != nil {
Expand All @@ -43,6 +46,7 @@ func AnalyzeFile(filename string, language *Language, opts *ClocOptions) *ClocFi
return AnalyzeReader(filename, language, fp, opts)
}

// AnalyzeReader is analyzing file for io.Reader.
func AnalyzeReader(filename string, language *Language, file io.Reader, opts *ClocOptions) *ClocFile {
if opts.Debug {
fmt.Printf("filename=%v\n", filename)
Expand Down

0 comments on commit 54204ce

Please sign in to comment.