Skip to content

Command-line tool to display a list of TODOs written within a Go package.

Notifications You must be signed in to change notification settings

jeandeaual/go-todo-checker

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

37 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

TODO Checker

Command-line tool to display a list of TODOs written within a Go package.

Prerequisites

Go 1.6 or later.

Build Instructions

Make sure the repository is located in GOPATH and run make or the following command:

go build ./cmd/todo

Usage

Usage: todo [PACKAGE]

Flags:
  -pattern string
        Pattern to search for in the package comments (only used without -server) (default "TODO")
  -port int
        Server port number (only used with -server) (default 80)
  -server
        Run the program in server mode

Examples

Command-line

$ ./todo fmt
/usr/lib/go/src/fmt/scan.go:732:
TODO: accept N and Ni independently?

Server mode

  • Run the server

    $ ./todo -server -port 8080
    2006/01/02 15:04:05 Listening on port 8080
    
  • Query the API:

    $ curl -w "\n" http://localhost:8080/fmt
    [{"filename":"/usr/lib/go/src/fmt/scan.go","line":732,"text":"TODO: accept N and Ni independently?\n"}]
    
    $ curl -w "\n" http://localhost:8080/net/http/httptest
    []
    
    $ curl -w "\n" http://localhost:8080/bytes?pattern=FIXME
    [{"filename":"/usr/lib/go/src/bytes/buffer.go","line":25,"text":"FIXME: it would be advisable to align Buffer to cachelines to avoid false\nsharing.\n"}]
    

Testing

Run the tests using make test or the following command:

go test -v ./...

To generate a code coverage report using make coverage or the following commands:

go test -coverpkg=./... -coverprofile="coverage.out" ./...
go tool cover -html="coverage.out"

API Documentation

The documentation of the HTTP API (when using the -server flag) can be generated using make doc, or by following these instructions:

  • Install swag

    • go get -u github.com/swaggo/swag/cmd/swag
    • Make sure $GOPATH/bin is in your $PATH
  • Run the tool

    swag init -g ./cmd/todo/api.go
    

This will generate docs/swagger.yaml and docs/swagger.json, which can be viewed using the Swagger editor for example.

The documentation is also available as an OpenAPI specification file, which can be viewed using the same tool as the auto-generated files.

About

Command-line tool to display a list of TODOs written within a Go package.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published