Go Coverage in Shell: a tool for exploring Go Coverage reports from the command line

gocovsh

gocovsh is a CLI viewer of Go test coverage reports.

Installation

$ go install github.com/orlangure/gocovsh

More installation options will follow.

Usage

  1. Generate Go coverage report at your project's root with

    $ go test -cover -coverprofile coverage.out

    For more information about generating Go coverage reports, see my blog post.

  2. Run gocovsh at the same folder with coverage.out report and go.mod file (go.mod is required).

    $ gocovsh
    $ gocovsh --profile profile.out # for other coverage profile names
  3. Use j/k/enter/esc keys to explore the report. See built-in help for more key-bindings.

image

image

Owner
Yury Fedorov
Software Developer
Yury Fedorov
Comments
  • feat: sort by percentage (lowest to highest)

    feat: sort by percentage (lowest to highest)

    Basically, sorts from the lowest percentage to the highest.

    image

    Because seeing this is not very helpful to spot defects

    image

    The tests will not pass anymore because the golden file testing strategy is a nightmare to work with, especially when you have blank lines filled with spaces, as you can see on the screenshot below.

    image

    Thanks for this tool, it is very convenient !

  • Bug: nil pointer

    Bug: nil pointer

    Caught panic:
    
    runtime error: invalid memory address or nil pointer dereference
    
    Restoring terminal...
    
    goroutine 1 [running]:
    runtime/debug.Stack()
            /usr/lib/go/src/runtime/debug/stack.go:24 +0x65
    runtime/debug.PrintStack()
            /usr/lib/go/src/runtime/debug/stack.go:16 +0x19
    github.com/charmbracelet/bubbletea.(*Program).StartReturningModel.func3()
            /home/tyler/go/pkg/mod/github.com/charmbracelet/[email protected]/tea.go:350 +0x95
    panic({0x52c720, 0x660ae0})
            /usr/lib/go/src/runtime/panic.go:1047 +0x266
    github.com/charmbracelet/bubbles/list.(*Model).updatePagination(0xc00011ac80)
            /home/tyler/go/pkg/mod/github.com/charmbracelet/[email protected]/list/list.go:656 +0x2d1
    github.com/charmbracelet/bubbles/list.(*Model).SetItems(0xc00011ac80, {0xc000110500, 0x4, 0x4})
            /home/tyler/go/pkg/mod/github.com/charmbracelet/[email protected]/list/list.go:293 +0x108
    github.com/orlangure/gocovsh/internal/model.(*Model).onProfilesLoaded(0xc00011ac80, {0xc000070540, 0x4, 0x0})
            /home/tyler/go/pkg/mod/github.com/orlangure/[email protected]/internal/model/model.go:210 +0x2db
    github.com/orlangure/gocovsh/internal/model.(*Model).Update(0xc00011ac80, {0x522f40, 0xc00000c0f0})
            /home/tyler/go/pkg/mod/github.com/orlangure/[email protected]/internal/model/model.go:100 +0x308
    github.com/charmbracelet/bubbletea.(*Program).StartReturningModel(0xc000138180)
            /home/tyler/go/pkg/mod/github.com/charmbracelet/[email protected]/tea.go:534 +0x139c
    github.com/charmbracelet/bubbletea.(*Program).Start(...)
            /home/tyler/go/pkg/mod/github.com/charmbracelet/[email protected]/tea.go:543
    github.com/orlangure/gocovsh/internal/program.(*Program).Run(0xc0001280b0)
            /home/tyler/go/pkg/mod/github.com/orlangure/[email protected]/internal/program/program.go:116 +0x36c
    main.main()
            /home/tyler/go/pkg/mod/github.com/orlangure/[email protected]/main.go:21 +0x119
    
    
  • Bug: full file paths in coverage output (windows)

    Bug: full file paths in coverage output (windows)

    Describe the bug It doesn't work on windows

    To Reproduce Steps to reproduce the behavior:

    1. go install github.com/orlangure/gocovsh@latest
    2. cd Some/Directory
    3. git clone https://github.com/tsoding/snitch
    4. cd snitch
    5. go test -v -cover -coverprofile coverage.out
    6. gocovsh --profile coverage.out
    7. Enter on a selected file.

    Expected behavior File paths are relative in the cover.out file eg. github.com/tsoding/snitch/logcmd.go:26.33,28.4 1 0. I don't think this issue is package-specific (snitch).

    Screenshots Files After Opening a file

    Desktop (please complete the following information):

    • OS: Windows 10
    • Info:
        Edition	Windows 10 Home Single Language
        Version	21H1
        Installed on	‎8/‎7/‎2020
        OS build	19043.1566
        Experience	Windows Feature Experience Pack 120.2212.4170.0
      
    • Terminal emulator: cmd.exe, clink, alacritty

    Additional context Not sure if this is windows specific but I'm on windows.

  • Added go-recipes badge

    Added go-recipes badge

    Hello, Hi!! 👋🏻

    I like your project and I think broader Go community will benefit from it too.

    Thus, I added it to the curated list of Go tools.

    I hope this badge will serve as a mark of quality and appreciation to your project.

    Once again, thank you for your work!!

    ❤️

    -- Nikolay

  • Add themes

    Add themes

    Changes made:

    • [x] Created a Theme struct for new themes and used Catppuccin themes as a starting point.

    Supported themes:

    • Catppuccin "mocha", "macchiatto", and "latte" (light theme)
    • Default (anything other than those values

    One thing I noticed and haven't been able to debug is that the first time I run gocovsh it gives a nil pointer reference, but the second time I run it, there's no problem. Attached a GIF for your reference which includes a demo of both the error and the working style for latte theme.

    gocovsh-themes

    #4

  • fix: initialize list with model

    fix: initialize list with model

    Model.list didn't get properly initialized until Model.updateWindowSize got called. In some situations onProfilesLoaded can arrive before the terminal dimensions have been retrieved however, and calling it will call updatePagination which accesses the still uninitialized (nil) item delegate. This causes a crash.

    Fixes #38.

  • Accept

    Accept "git diff" as input

    In addition to supporting file list input, this commit adds support for raw "git diff" output. In this case, only the changed files will appear, and only the lines marked as "added" in the diff will be shown. For every such line, its coverage status will be reported of course (red/green/gray).

  • feat: use go mod proxying

    feat: use go mod proxying

    This enables read build info both on binaries built by goreleaser, as well as installed with go install directly.

    More info: https://carlosbecker.com/posts/supply-chain-goreleaser-go-mod-proxy/

  •  Support explicit selection of files to display

    Support explicit selection of files to display

    In larger projects, running gocovsh after making a small change will cause redundant work to find the changed files in the long, multi-page list. This flow appears to be the most common for a routine work: usually the developer will want to view their change coverage, and not the entire project coverage.

    To achieve this goal, the list of files should be piped into gocovsh. It allows to keep the "list" operation abstract: it can be a git diff with any arguments the user desires, if the result is a simple multi-line list of files.

    For example, the suggested usage would be:

    git diff --name-only | gocovsh		# view non-stashed changes
    git diff --name-only master | gocovsh	# view changes relative to master
    
  • Calculate total coverage value per file

    Calculate total coverage value per file

    The value should be displayed in both list and code views:

    • in list view, next to every file name
    • in code view, either near the name at the top, or at the bottom near the progress indicator
  • Support 3 states of help: hidden, visible, full

    Support 3 states of help: hidden, visible, full

    After a couple usages the keys should be memorized, so the users might want to hide the help completely to add another row to the code view/list.

    In the future, help section state will be persisted in the optional configuration file, so that for every new gocovsh session the menu will be in the selected state.

    Closes #3

  • Allow sorting files list by coverage

    Allow sorting files list by coverage

    For larger projects, it might be useful to support sorting the entries in the list by their total coverage. Another potentially useful mode could be sorting by the number of non-covered statements: show the files with the most potential improvements to make first.

  • Consider using cover.Boundary objects to colorize coverage

    Consider using cover.Boundary objects to colorize coverage

    https://github.com/golang/tools/blob/master/cmd/cover/html.go includes the logic of the built-in html based coverage viewer. It uses boundary objects that essentially mark where to start every color block. It should be more precise and battle tested than the original procedure that I wrote.

An open-source GitLab command line tool bringing GitLab's cool features to your command line
An open-source GitLab command line tool bringing GitLab's cool features to your command line

GLab is an open source GitLab CLI tool bringing GitLab to your terminal next to where you are already working with git and your code without switching

Dec 30, 2022
A command line tool to prompt for a value to be included in another command line.

readval is a command line tool which is designed for one specific purpose—to prompt for a value to be included in another command line. readval prints

Dec 22, 2021
A tool for exploring each layer in a docker image
A tool for exploring each layer in a docker image

dive A tool for exploring a docker image, layer contents, and discovering ways to shrink the size of your Docker/OCI image. To analyze a Docker image

Jan 9, 2023
painless task queue manager for shell commands with an intuitive cli interface (execute shell commands in distributed cloud-native queue manager).

EXEQ DOCS STILL IN PROGRESS. Execute shell commands in queues via cli or http interface. Features Simple intuitive tiny cli app. Modular queue backend

Dec 14, 2022
ap 是一个 shell 工具,可以让其它 shell 命令的输出能够自动进入交互翻页模式

ap -- auto-pager ap 是一个 shell 工具,可以让其它 shell 命令的输出能够自动进入交互翻页模式。 ap 由两部分组成,一个 Go 语言编写的二进制程序,负责捕获命令的输出并支持翻页, 和一组 shell 脚本,负责为用户指定的命令清单创建与之同名的 wrapper。 经

Apr 12, 2022
CLI for exploring AWS EC2 Spot inventory. Inspect AWS Spot instance types, saving, price, and interruption frequency.

spotinfo The spotinfo is a command-line tool that helps you determine AWS Spot instance types with the least chance of interruption and provides the s

Dec 19, 2022
Tools for exploring OpenVG
Tools for exploring OpenVG

Testbed for exploring OpenVG on the Raspberry Pi. First program Here is the graphics equivalent of "hello, world" // first OpenVG program // Anthony S

Dec 30, 2022
git-xargs is a command-line tool (CLI) for making updates across multiple Github repositories with a single command.
git-xargs is a command-line tool (CLI) for making updates across multiple Github repositories with a single command.

Table of contents Introduction Reference Contributing Introduction Overview git-xargs is a command-line tool (CLI) for making updates across multiple

Dec 31, 2022
git-xargs is a command-line tool (CLI) for making updates across multiple GitHub repositories with a single command
git-xargs is a command-line tool (CLI) for making updates across multiple GitHub repositories with a single command

git-xargs is a command-line tool (CLI) for making updates across multiple GitHub repositories with a single command. You give git-xargs:

Feb 5, 2022
A command line tool for simplified docker volume command built with go

dockervol A command line tool for simplified docker volume command built with go. Features: Remove anonymous volume (beta) Remove volume by matching n

Dec 18, 2021
Query git repositories with SQL. Generate reports, perform status checks, analyze codebases. 🔍 📊
Query git repositories with SQL. Generate reports, perform status checks, analyze codebases. 🔍 📊

askgit is a command-line tool for running SQL queries on git repositories. It's meant for ad-hoc querying of git repositories on disk through a common interface (SQL), as an alternative to patching together various shell commands.

Jan 3, 2023
Scrappy is a cli tool that allows multiple web scrappers to monitor periodically for a basic ruleset coverage and inform users when the criteria have been met.

Scrappy - A multi-type web scrapper with alerting Scrappy is a cli tool that allows multiple web scrappers to monitor periodically for a basic ruleset

Nov 7, 2021
Run any shell command in a temporary proxy environment.

Run any shell command in a temporary proxy environment.

Jun 2, 2022
fofax is a fofa query tool written in go, positioned as a command-line tool and characterized by simplicity and speed.
fofax is a fofa query tool written in go, positioned as a command-line tool and characterized by simplicity and speed.

fofaX 0x00 Introduction fofax is a fofa query tool written in go, positioned as

Jan 8, 2023
Go package to make lightweight ASCII line graph ╭┈╯ in command line apps with no other dependencies.
Go package to make lightweight ASCII line graph ╭┈╯ in command line apps with no other dependencies.

asciigraph Go package to make lightweight ASCII line graphs ╭┈╯. Installation go get github.com/guptarohit/asciigraph Usage Basic graph package main

Jan 8, 2023
Package command provide simple API to create modern command-line interface

Package command Package command provide simple API to create modern command-line interface, mainly for lightweight usage, inspired by cobra Usage pack

Jan 16, 2022
Watcher - A simple command line app to watch files in a directory for changes and run a command when files change!

Watcher - Develop your programs easily Watcher watches all the files present in the directory it is run from of the directory that is specified while

Mar 27, 2022
An unsupervised coverage-guided kernel fuzzer

syzkaller - kernel fuzzer syzkaller is an unsupervised coverage-guided kernel fuzzer. Linux kernel fuzzing has the most support, akaros, freebsd, fuch

Oct 27, 2021
🎄 Go code coverage to SVG treemap

?? Go cover to Treemap Useful when you have large project with lots of files and packages $ go install github.com/nikolaydubina/go-cover-treemap@lates

Jan 9, 2023