• Stars
    star
    703
  • Rank 64,412 (Top 2 %)
  • Language
    Go
  • License
    MIT License
  • Created over 8 years ago
  • Updated over 1 year ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

A little fast cloc(Count Lines Of Code)

gocloc

GoDoc ci Go Report Card Docker Pulls Docker Image Size

A little fast cloc(Count Lines Of Code), written in Go. Inspired by tokei.

Installation

require Go 1.19+

$ go install github.com/hhatto/gocloc/cmd/gocloc@latest

Arch Linux user can also install from AUR: gocloc-git.

Usage

Basic Usage

$ gocloc .
$ gocloc .
-------------------------------------------------------------------------------
Language                     files          blank        comment           code
-------------------------------------------------------------------------------
Markdown                         3              8              0             18
Go                               1             29              1            323
-------------------------------------------------------------------------------
TOTAL                            4             37              1            341
-------------------------------------------------------------------------------

Via Docker

with dockerhub

$ docker run --rm -v "${PWD}":/workdir hhatto/gocloc .

with GitHub Packages on GitHub Actions

jobs:
  build:
    name: example of code measurement using gocloc
    runs-on: ubuntu-18.04
    steps:
      - uses: actions/checkout@master

      - name: Login GitHub Registry
        run: docker login docker.pkg.github.com -u owner -p ${{ secrets.GITHUB_TOKEN }}

      - name: Run gocloc
        run: docker run --rm -v "${PWD}":/workdir docker.pkg.github.com/hhatto/gocloc/gocloc:latest .

Integration Jenkins CI

use SLOCCount Plugin.

$ cloc --by-file --output-type=sloccount . > sloccount.scc
$ cat sloccount.scc
398 Go      ./main.go
190 Go      ./language.go
132 Markdown        ./README.md
24  Go      ./xml.go
18  Go      ./file.go
15  Go      ./option.go

Support Languages

use --show-lang option

$ gocloc --show-lang

Performance

  • CPU 3.8GHz 8core Intel Core i7 / 32GB 2667MHz DDR4 / MacOSX 13.3.1
  • cloc 1.96
  • tokei 12.1.2 compiled with serialization support: json
  • gocloc a88edc5
  • target repository is golang/go commit:f742ddc

cloc

$ time cloc .
   12003 text files.
   11150 unique files.
    1192 files ignored.

8 errors:
Line count, exceeded timeout:  ./src/cmd/dist/build.go
Line count, exceeded timeout:  ./src/cmd/trace/static/webcomponents.min.js
Line count, exceeded timeout:  ./src/net/http/requestwrite_test.go
Line count, exceeded timeout:  ./src/vendor/golang.org/x/net/idna/tables10.0.0.go
Line count, exceeded timeout:  ./src/vendor/golang.org/x/net/idna/tables11.0.0.go
Line count, exceeded timeout:  ./src/vendor/golang.org/x/net/idna/tables12.0.0.go
Line count, exceeded timeout:  ./src/vendor/golang.org/x/net/idna/tables13.0.0.go
Line count, exceeded timeout:  ./src/vendor/golang.org/x/net/idna/tables9.0.0.go

github.com/AlDanial/cloc v 1.96  T=35.07 s (317.9 files/s, 78679.3 lines/s)
-----------------------------------------------------------------------------------
Language                         files          blank        comment           code
-----------------------------------------------------------------------------------
Go                                9081         205135         337681        1779107
Text                              1194          11530              0         210849
Assembly                           563          15549          21625         122329
HTML                                17           3197             78          24983
C                                  139           1324            982           6895
JSON                                20              0              0           3122
CSV                                  1              0              0           2119
Markdown                            27            674            106           1949
Bourne Shell                        16            253            868           1664
JavaScript                          10            234            221           1517
Perl                                10            173            171           1111
C/C++ Header                        26            145            346            724
Bourne Again Shell                  16            120            263            535
Python                               1            133            104            375
CSS                                  3              4             13            337
DOS Batch                            5             56             66            207
Windows Resource File                4             23              0            146
Logos                                2             16              0            101
Dockerfile                           2             13             15             47
C++                                  2             11             14             24
make                                 5              9             10             21
Objective-C                          1              2              3             11
Fortran 90                           2              1              3              8
awk                                  1              1              6              7
YAML                                 1              0              0              5
MATLAB                               1              1              0              4
-----------------------------------------------------------------------------------
SUM:                             11150         238604         362575        2158197
-----------------------------------------------------------------------------------
cloc .  33.70s user 1.48s system 99% cpu 35.237 total

tokei

$ time tokei --sort code  --exclude "**/*.txt" .
===============================================================================
 Language            Files        Lines         Code     Comments       Blanks
===============================================================================
 Go                   9242      2330107      1812147       318036       199924
 GNU Style Assembly    565       159534       127093        16888        15553
 C                     143         9272         6949         1000         1323
 JSON                   21         3122         3122            0            0
 Shell                  16         2785         2267          342          176
 JavaScript             10         1972         1520          218          234
 Perl                    9         1360         1032          170          158
 C Header               27         1222          727          349          146
 BASH                   16          918          521          279          118
 Python                  1          612          421           70          121
 CSS                     3          354          337           13            4
 Autoconf                9          283          274            0            9
 Batch                   5          329          207           66           56
 Alex                    2          117          101            0           16
 Dockerfile              2           75           47           15           13
 C++                     2           49           24           14           11
 Makefile                5           40           20           10           10
 Objective-C             2           21           15            3            3
 FORTRAN Modern          2           12            8            3            1
 Markdown               18         2402            0         1853          549
-------------------------------------------------------------------------------
 HTML                   17        19060        18584           49          427
 |- CSS                  4         2071         1852           10          209
 |- HTML                 1          219          212            0            7
 |- JavaScript           8         6920         6876           16           28
 (Total)                          28270        27524           75          671
===============================================================================
 Total               10117      2533646      1975416       339378       218852
===============================================================================
tokei --sort code --exclude "**/*.txt" .  0.76s user 0.50s system 562% cpu 0.224 total

gocloc

$ time gocloc --exclude-ext=txt .
-------------------------------------------------------------------------------
Language                     files          blank        comment           code
-------------------------------------------------------------------------------
Go                            9096         205242         352844        1764503
Assembly                       563          15555          21624         122324
HTML                            17           3197            212          24849
C                              139           1324            983           6894
JSON                            20              0              0           3122
BASH                            27            345           1106           2122
Markdown                        18            549             28           1825
JavaScript                      10            234            218           1520
C Header                        26            145            346            724
Perl                            10            173            584            698
Python                           1            133            104            375
CSS                              3              4             13            337
Batch                            5             56              0            273
Plan9 Shell                      4             23             50             96
Bourne Shell                     5             28             24             78
C++                              2             11             14             24
Makefile                         5             10             10             20
Objective-C                      2              3              3             15
FORTRAN Modern                   2              1              3              8
Awk                              1              1              6              7
-------------------------------------------------------------------------------
TOTAL                         9956         227034         378172        1929814
-------------------------------------------------------------------------------
gocloc --exclude-ext=txt .  0.65s user 0.51s system 119% cpu 0.970 total

License

MIT

More Repositories

1

autopep8

A tool that automatically formats Python code to conform to the PEP 8 style guide.
Python
4,557
star
2

nude.py

Nudity detection with Python
Python
915
star
3

pgmagick

pgmagick is a yet another boost.python based wrapper for GraphicsMagick/ImageMagick.
C++
146
star
4

python-hoedown

The Python binding for hoedown, a markdown parsing library.
HTML
50
star
5

gorst

Go implementation of reStructuredText
Go
33
star
6

pyrapidjson

Python binding for rapidjson
C++
26
star
7

poyonga

Python Groonga Client
Python
22
star
8

cargo-strict

avoid unwrap() method
Rust
18
star
9

kamasu

HTTP/HTTPS/HTTP2 Proxy for PHP Built-in Server, written in Rust
Rust
15
star
10

gruffy

Gruffy is Python implemetation of Gruff(Ruby's Graphing Library http://nubyonrails.com/pages/gruff)
Python
14
star
11

goroo

Yet Another Groonga Client for Go
Go
11
star
12

peg-rst

reStructuredText in C
C
11
star
13

otamapy

otama Python Interface
C
11
star
14

meow

Yet another markdown/reST preview server (based on moo)
JavaScript
9
star
15

zsh_completions

my zsh compeltion functions
Python
8
star
16

jc

command-line tool for jenkins-ci
Go
8
star
17

ftcat

markdown live previewer
Go
7
star
18

kuroko

Minimalistic Python Task Executor
Python
7
star
19

nem2-rs

NEM SDK for Rust
Rust
6
star
20

boom-rust

Rust implementation of boom
Rust
6
star
21

zoth

CLI Cache Tool
Rust
6
star
22

cargo-quickfix

Rust
5
star
23

fpath

fast Python's os.path module written in Rust
Python
5
star
24

pit-rs

pit in Rust
Rust
4
star
25

php-otama

PHP extension for otama
C
4
star
26

pyjsmn

Python extension for jsmn
C
4
star
27

fcsv

yet another Python csv module written in Rust
Python
4
star
28

cargobench-plot

Rust
3
star
29

python-pegmarkdown

Python binding for PEG-markdown
Python
3
star
30

backlog-rs

Nulab's Backlog API bindings for Rust
Rust
3
star
31

genzshcomp

Python
3
star
32

ray-tracing-in-one-weekend-in-rust

Rust
3
star
33

python-workq

Python Client for Workq (https://github.com/iamduo/workq)
Python
3
star
34

tamatebako

Rust
3
star
35

aiogrn

asyncio Groonga Client library
Python
2
star
36

pixiv-isucon2016-rust

Rust
2
star
37

pgstatprof

sampling profiler for PostgreSQL
Rust
2
star
38

nanairo

nanairo is a Go library that make the colorized output of terminal applications
Go
2
star
39

go-rlogger

rlogger with Go
Go
2
star
40

go-genzshcomp

generate zsh completion function from Go flag's help text
Go
2
star
41

hhatto

2
star
42

pywebp

Yet Another Python libwebp wrapper.
C
2
star
43

nuxt-vercel-boilerplate

Vue
2
star
44

sphinxcontrib-gruffygen

render Graph Extension for Sphinx
Python
2
star
45

fast-woothee-python

Rust
1
star
46

jubatus-rust-client

jubatus client in Rust
Rust
1
star
47

fastapi-snippets

FastAPI snippet
Python
1
star
48

rust-rlogger

rlogger with Rust
Rust
1
star
49

openweathermap-cli

CLI tool for OpenWeatherMap (written by Go)
Go
1
star
50

hhatto.github.io

HTML
1
star
51

slowfast

Two Python code compare using timeit module
Python
1
star
52

ss-ogp-image

TypeScript
1
star
53

rcoin

blockchain example written in Rust
Rust
1
star
54

zci

Zsh Completion function Installer
Python
1
star
55

go-scrapbox-parser

Go
1
star
56

libvmod-woothee

user agent parser for VMOD (Rust implementation)
M4
1
star
57

python-kcipher2

Python implementation of KCipher2 stream cipher
Python
1
star
58

goodc

goodcheck clone written in Rust
Rust
1
star
59

homebrew-pgmagick

brew for pgmagick
Ruby
1
star
60

homebrew-python-mecab

homebrew for python-mecab
Ruby
1
star
61

rust-ens

Rust ENS(Ethereum Name Service) interface
Rust
1
star
62

klip

Go parser for the Kindle's clippings.txt file
Go
1
star
63

go-coverhtml-ng

next-generatation go tool cover -html
1
star
64

homebrew-otama

homebrew for otama
Ruby
1
star
65

wwup-in-rust

[unofficial] example code for Working With Unix Processes in Rust
Rust
1
star