go-recipes

nikolaydubinaMIT活跃维护

一份 Go 项目开发工具清单,收录基准测试、代码生成、代码可视化、文档生成等实用命令行工具,帮 Go 开发者快速找到趁手的工具。

🦩 Tools for Go projects

2025-12发布于 2025-12-21 06:37 UTC4,810star187fork同步于 2026-11-11 05:35 UTC

怎么上手

由 README 提炼,执行前请确认
go build -gcflags="-m -m" . 2>&1 | grep inline
硬件要求按 README 说明

README 未说明

下载:源码 zip·GitHub Releases(安装包)本站不镜像安装包

项目说明

由 README 自动翻译提炼

一份 Go 项目常用与冷门工具清单,按测试、依赖、可视化等场景给出可直接复制的命令

一份 Go 项目开发工具清单,收录基准测试、代码生成、代码可视化、文档生成等实用命令行工具,帮 Go 开发者快速找到趁手的工具。

核心能力

  • 按测试、依赖、代码可视化、构建等主题分类收录 Go 工具
  • 每条工具都给出可直接复制的命令行用法
  • 覆盖覆盖率可视化、变异测试、goroutine 泄漏检测等测试场景
  • 收录依赖图、许可证扫描、架构约束检查等依赖管理工具
  • 包含 gcflags、ldflags、PGO 等编译优化技巧

容易踩的坑

这是工具清单而非可安装的软件包,需按条目自行安装对应工具;部分条目标注为 :gift: 的属于较少见或实验性工具,使用前需自行验证;示例命令依赖具体 Go 版本,如 PGO 需 Go 1.20 及以上

内容由模型根据 README 生成,可能不完整或不准确,以官方文档为准。看原文 README

最近发版

5 个版本2025-12
  1. 2025-12🎄2025 Christmas Update最新正式版2025-12-21 · 2025-12-21 06:37 UTC
    • 9 new tools
    • 5 new guides
    • removed outdated AI section

    Thanks to @alexandear @matm @nightnoryu

    Merry Christmas everyone! 🎅🏻

  2. v5🎁 2024 Christmas Update2024-12-19 · 2024-12-19 08:29 UTC
    查看更新说明
    • 37 new entries
    • clean up broken links
    • removed "unmaintained" icon
    • added entries to Security
    • 2023-13-24 ~ 2024-12-24
  3. 2023-12-11🎅🏻 2023 Christmas Update2023-12-11 · 2023-12-11 09:22 UTC
    查看更新说明
    • 179 entries (16 new)
    • updated UI
    • project markers: archived 🏚️ ; new 🎊 ;
  4. 2023-06-06🍉 2023 Summer Update2023-06-06 · 2023-06-06 12:42 UTC
    查看更新说明
    • 160 entries (90 new)
    • new sections: AI tools, Education, Monitoring, Security, Style Guide
    • added links to all entries
    • updated style
  5. 2022-10🎃 2022 Fall Update2022-10-08 · 2022-10-08 12:37 UTC
    查看更新说明
    • 70 entries (45 new)
    • new sections: Documentation, Benchmarking, Build, Code Generation, Static Analysis, Code Visualization
    • added authors
    • improved examples and links
    • improved navigation
    • automatic generation

用户点评

登录用户的真实使用记录,可按版本和硬件筛选
共 0 条

    还没有人点评。第一个说出真实体验的人最有价值。

    README 原文

    未翻译

    Contents

    Test

    ⏫ Continuous Tests Monitoring with codecov.io

    Track tests duration, errors, and flakiness. Run JUnit test output converter and submit results to codecov.io via GitHub Action. — https://codecov.io

    go test -coverprofile=coverage.out -cover -json ./... | gotestsum --junitfile tests.xml
    

    Requirements

    go install gotest.tools/gotestsum@latest
    

    ⏫ Make treemap of coverage with go-cover-treemap

    Visualize distribution of code coverage in your project. This helps to identify code areas with high and low coverage. Useful when you have large project with lots of files and packages. This 2D "image-hash" of your project should be more representative than a single number. Also available at https://nikolaydubina.github.io/go-cover-treemap/. — @nikolaydubina

    go test -coverprofile cover.out ./...
    go-cover-treemap -coverprofile cover.out > out.svg
    

    Requirements

    go install github.com/nikolaydubina/go-cover-treemap@latest
    

    ⏫ Browse coverage

    This is very helpful tool from the official Go toolchain. Similar visualization is integrated into VSCode and GoLand, but can be used separately.

    go test -coverprofile cover.out ./...
    go tool cover -html=cover.out
    

    ⏫ Browse coverage with gocov-html

    Browse code coverage in statically generated HTML page. Multiple styles are supported. You may need to convert coverage report into gocov format. — @matm

    gocov test strings | gocov-html -t golang > strings.html
    gocov test encoding/csv strings | gocov-html -t kit > strings.html
    gocov test strings|./gocov-html -cmax 90 > strings.html # show functions with <90% coverage
    

    Requirements

    go install github.com/axw/gocov/gocov@latest
    go install github.com/matm/gocov-html/cmd/gocov-html@latest
    

    ⏫ Browse coverage with xgo

    The displayed coverage is a combination of coverage and git diff. By default, only modified lines were shown. This helps to quickly locate changes that were not covered, and add tests for them incrementally. — @xhd2015

    xgo tool coverage serve cover.out
    

    Requirements

    go install github.com/xhd2015/xgo/cmd/xgo@latest
    

    ⏫ Browse coverage in terminal with gocovsh

    Browse code coverage similarly to HTML provided by official Go toolchain, but in terminal. Other notable features are package level statistics, coverage only for changed files. — @orlangure

    go test -cover -coverprofile coverage.out
    gocovsh                        # show all files from coverage report
    git diff --name-only | gocovsh # only show changed files
    git diff | gocovsh             # show coverage on top of current diff
    gocovsh --profile profile.out  # for other coverage profile names
    

    Requirements

    go install github.com/orlangure/gocovsh@latest
    

    ⏫ Pretty print coverage in terminal with nikandfor/cover

    It is similar to go tool cover -html=cover.out but in terminal. You can filter by functions, packages, minimum coverage, and more. — @nikandfor

    cover
    

    Requirements

    go install github.com/nikandfor/cover@latest
    

    ⏫ Run coverage collector server with goc

    This tool allows to collect coverage as soon as code is executed. — @qiniu

    goc server
    goc build
    goc profile
    

    Requirements

    go install github.com/qiniu/goc@latest
    

    ⏫ Visualize live coverage in VSCode with goc

    Official Go VSCode plugin already has coverage highlighting. In addition to that, this tool shows covered lines as soon as they are executed. This can be useful for running manual integration or system tests or debugging. — @qiniu

    Requirements

    go install github.com/qiniu/goc@latest
    

    ⏫ Detect drops in coverage with go-test-coverage

    This tool is designed to report issues when test coverage falls below a specified threshold. Likely you would want to use it in the CI. — @vladopajic

    go-test-coverage --config=./.testcoverage.yml
    

    Requirements

    go install github.com/vladopajic/go-test-coverage/v2@latest
    

    ⏫ :gift: Comment code coverage reports in pull request with go-coverage-report

    A CLI tool and GitHub Action to post Go code coverage reports as a comment on your pull requests. — @fgrosse

    ⏫ :gift: Debug with Differential Coverage

    This is a useful basic technique that should be more widely known (just like bisect). Read more in the blog post. — @rsc

    ⏫ :gift: Manipulate coverage profiles with gopherage

    Kubernetes test-infra contains a couple of useful granular tools to manipulate coverage profiles. — @kubernetes

    aggregate [files...]
    diff [first] [second]
    filter [file]
    html [coverage]
    junit [profile]
    merge [files...]
    metadata [...fields]
    

    Requirements

    go install k8s.io/test-infra/gopherage/cmd/aggregate@latest
    go install k8s.io/test-infra/gopherage/cmd/diff@latest
    go install k8s.io/test-infra/gopherage/cmd/filter@latest
    go install k8s.io/test-infra/gopherage/cmd/html@latest
    go install k8s.io/test-infra/gopherage/cmd/junit@latest
    go install k8s.io/test-infra/gopherage/cmd/metadata@latest
    go install k8s.io/test-infra/gopherage/cmd/merge@latest
    

    ⏫ Shuffle tests

    This is less known option that is disabled by default. However, for robust test suite it is beneficial. More test flags and full description is available at go help testflag.

    go test -shuffle=on
    

    ⏫ Run tests sequentially

    Use when you need to synchronize tests, for example in integration tests that share environment. Official documentation.

    go test -p 1 -parallel 1 ./...
    

    ⏫ Run tests in parallel

    Add t.Parallel to your tests case function bodies. As per documentation, by default -p=GOMAXPROCS and -parallel=GOMAXPROCS when you run go test. Different packages by default run in parallel, and tests within package can be enforced to run in parallel too. Make sure to copy test case data to new variable, why explained here. Official documentation.

    ...
    for _, tc := range tests {
        tc := tc
        t.Run(tc.name, func(t *testing.T) {
            t.Parallel()
            ...
    

    ⏫ Run all Fuzz tests

    The standard tool runs only a single fuzz test. Use the following to run all fuzz tests in a package.

    go test -list . | grep Fuzz | xargs -P 8 -I {} go test -fuzz {} -fuzztime 5s .
    

    ⏫ :gift: Fuzz Go binaries using LibAFL with GoLibAFL

    This project provides a setup for fuzzing Go binaries using LibAFL. By leveraging Go native libFuzzer-compatible instrumentation (sancov_8bit), we enable advanced fuzzing capabilities beyond Go built-in fuzzing support. — @srlabs

    ⏫ Detect goroutine leaks with goleak

    Instrument your test cases with verification call. Alternatively, you can add single call in TestMain. This tool was recommended by Pyroscope in blog. — Uber

    func TestA(t *testing.T) {
      defer goleak.VerifyNone(t)
      ...
    }
    

    Requirements

    go get -u go.uber.org/goleak
    

    ⏫ Detect goroutine leaks with leaktest

    Refactored, tested variant of the goroutine leak detector found in both net/http tests and the cockroachdb source tree. You have to call this library in your tests. — @fortytw2

    func TestPoolContext(t *testing.T) {
      ctx, cancel := context.WithTimeout(context.Background(), time.Second)
      defer cancel()
      defer leaktest.CheckContext(ctx, t)()
    
      go func() {
        for {
          time.Sleep(time.Second)
        }
      }()
    }
    

    ⏫ Visualize test runs with vgt

    This tool visualizes Go test results in a browser. It's helpful with understanding parallelism of tests and identifying slow tests. More information can be found in our blog post about optimizing Go tests parallelism. — @roblaszczak

    go test -json ./... | vgt
    

    Requirements

    go install github.com/roblaszczak/vgt@latest
    

    ⏫ Summarize go test with tparse

    This lightweight wrapper around STDOUT of JSON of go test will nicely render colorized test status, details of failures, duration, coverage, and package summary. — @mfridman

    set -o pipefail && go test ./... -json | tparse -all
    

    Requirements

    go install github.com/mfridman/tparse@latest
    

    ⏫ Decorate go test with richgo

    Add colors and enrich go test output. It can be used in CI pipeline and has lots of alternative visualizations and options. — @kyoh86

    richgo test ./...
    

    Requirements

    go install github.com/kyoh86/richgo@latest
    

    ⏫ Decorate go test with gotest

    Add colors to go test output. Very lightweight wrapper around go test STDOUT. — @rakyll

    gotest ./...
    

    Requirements

    go install github.com/rakyll/gotest@latest
    

    ⏫ Decorate go test with gotestsum

    This wrapper around go test renders test output in easy to read format. Also supports JUnit, JSON output, skipping slow tests, running custom binary. — @dnephin

    gotestsum --format dots
    

    Requirements

    go install gotest.tools/gotestsum@latest
    

    ⏫ Format go test results as documentation with gotestdox

    Decorates go test results by converting CamelCaseTestNames into readable sentences. — @bitfield

    gotestdox ./...
    

    Requirements

    go install github.com/bitfield/gotestdox/cmd/gotestdox@latest
    

    ⏫ Get slowest tests with gotestsum

    This is subcommand of gotestsum that processes JSON output of go test to find slowest tests. — @dnephin

    go test -json -short ./... | gotestsum tool slowest --threshold 500ms
    

    Example

    gotest.tools/example TestSomething 1.34s
    gotest.tools/example TestSomethingElse 810ms
    

    Requirements

    go install gotest.tools/gotestsum@latest
    

    ⏫ Auto-Instrument skipping slowest tests with gotestsum

    This is subcommand of gotestsum that processes JSON output of go test to find slowest tests and instruments test cases to skip them with t.Skip() statements. — @dnephin

    go test -json ./... | gotestsum tool slowest --skip-stmt "testing.Short" --threshold 200ms
    

    Example

    gotest.tools/example TestSomething 1.34s
    gotest.tools/example TestSomethingElse 810ms
    

    Requirements

    go install gotest.tools/gotestsum@latest
    

    ⏫ Automatically re-run failed tests with gotestsum

    Other useful option of gotestsum is to re-run failed tests. For example, if you have flaky tests that are idempotent, then re-running them may be a quick fix. — @dnephin

    gotestsum --rerun-fails --packages="./..."
    

    Requirements

    go install gotest.tools/gotestsum@latest
    

    ⏫ Make JUnit test report with gotestsum

    JUnit is widely used format for test reporting. — @dnephin

    go test -json ./... | gotestsum --junitfile unit-tests.xml
    

    Requirements

    go install gotest.tools/gotestsum@latest
    

    ⏫ Make JUnit test report with go-junit-report

    JUnit is widely used format for test reporting. Go benchmark output is also supported. — @jstemmer

    go test -v 2>&1 ./... | go-junit-report -set-exit-code > report.xml
    

    Requirements

    go install github.com/jstemmer/go-junit-report/v2@latest
    

    ⏫ Report each subtest as its own case with qualflare-go

    Turns go test -json into a report where every subtest is its own case with its own status and timing, and where labels, steps and files attached from inside a test travel with it. Also detects build failures, which produce no event in the JSON stream at all before Go 1.24. — @Qualflare

    qualflare-go ./...
    

    Requirements

    go install github.com/Qualflare/qualflare-go/cmd/qualflare-go@latest
    

    ⏫ Get packages without tests

    If code coverage does not report packages without tests. For example for CI or quality control.

    go list -json ./... | jq -rc 'select((.TestGoFiles | length)==0) | .ImportPath'
    

    Example

    github.com/gin-gonic/gin/ginS
    github.com/gin-gonic/gin/internal/json
    

    Requirements

    https://stedolan.github.io/jq/download/
    

    ⏫ Perform Mutation Testing with ooze

    Mutation testing is a technique used to assess the quality and coverage of test suites. It involves introducing controlled changes to the code base, simulating common programming mistakes. These changes are, then, put to test against the test suites. A failing test suite is a good sign. It indicates that the tests are identifying mutations in the code—it "killed the mutant". If all tests pass, we have a surviving mutant. This highlights an area with weak coverage. It is an opportunity for improvement. — @gtramontina

    go test -v -tags=mutation
    

    Requirements

    go get github.com/gtramontina/ooze
    

    ⏫ Perform Mutation Testing with avito-tech/go-mutesting

    This is fork of zimmski/go-mutesting. It has more mutators and latest updates. — @vasiliyyudin

    go-mutesting ./...
    
    for _, d := range opts.Mutator.DisableMutators {
      pattern := strings.HasSuffix(d, "*")
    
    -	if (pattern && strings.HasPrefix(name, d[:len(d)-2])) || (!pattern && name == d) {
    +	if (pattern && strings.HasPrefix(name, d[:len(d)-2])) || false {
        continue MUTATOR
      }
    }
    

    Requirements

    go install github.com/avito-tech/go-mutesting/cmd/go-mutesting@latest
    

    ⏫ :gift: Perform Mutation Testing with jonbaldie/go-mutesting

    Fork of avito-tech/go-mutesting with a much richer mutator set, CI quality gates, covered MSI %, baseline tracking, per-test filtering, parallel execution, and LLM-ready output. — @jonbaldie

    go-mutesting ./...
    
    for _, d := range opts.Mutator.DisableMutators {
      pattern := strings.HasSuffix(d, "*")
    
    -	if (pattern && strings.HasPrefix(name, d[:len(d)-2])) || (!pattern && name == d) {
    +	if (pattern && strings.HasPrefix(name, d[:len(d)-2])) || false {
        continue MUTATOR
      }
    }
    

    Requirements

    go install github.com/jonbaldie/go-mutesting/v2/cmd/go-mutesting@latest
    

    ⏫ Perform Mutation Testing with go-mutesting

    Find common bugs source code that would pass tests. This is earliest tool for mutation testing in Go. More functions and permutations were added in other mutation Go tools it inspired. — @zimmski

    go-mutesting ./...
    
    for _, d := range opts.Mutator.DisableMutators {
      pattern := strings.HasSuffix(d, "*")
    
    -	if (pattern && strings.HasPrefix(name, d[:len(d)-2])) || (!pattern && name == d) {
    +	if (pattern && strings.HasPrefix(name, d[:len(d)-2])) || false {
        continue MUTATOR
      }
    }
    

    Requirements

    go install github.com/zimmski/go-mutesting/cmd/go-mutesting@latest
    

    ⏫ Trace tests with go-test-trace

    Collect test execution as distributed traces. This is useful for tracking test duration, failures, and flakiness. Your distributed tracing storage, search, UI, exploration, dashboards, and alarms all automatically become test status collection. If you run integration tests in your CI, then it is particularly handy to investigate your integration tests the same way as real requests, such as Go processes, databases, etc. However, if you do not have distributed traces, it is still useful for ad hoc investigations. This tool processes STDOUT of go test. No automatic instrumentation is done. — @rakyll

    go-test-trace ./...
    

    Requirements

    # open telemetry collector
    # traces UI (Datadog, Jaeger, Honeycomb, NewRelic)
    go install github.com/rakyll/go-test-trace@latest
    

    ⏫ Speedup tests for large codebases

    As of 2023-12-11, large codebases may be slow to run tests by default commands. Compiling package test binaries first and executing them later can lead to significant overall speedup.

    go test -c ./pkg/mypackage -o my_pkg_test_binary.bin
    ./my_pkg_test_binary.bin | ... # normal test output post processing
    

    Dependencies

    ⏫ Upgrade dependencies

    In case VSCode or GoLand broke and you need to update dependencies manually.

    go get -u ./...
    

    ⏫ Get Go version of current module

    For example, setup correct Go version automatically from go.mod in CI.

    go mod edit -json | jq -r .Go
    

    Requirements

    https://stedolan.github.io/jq/download/
    

    ⏫ Get Go versions of upstream modules

    Use this when upgrading version of Go or finding old modules.

    go list -deps -json ./... | jq -rc 'select(.Standard!=true and .Module.GoVersion!=null) | [.Module.GoVersion,.Module.Path] | join(" ")' | sort -V | uniq
    

    Example

    1.11 github.com/ugorji/go/codec
    1.11 golang.org/x/crypto
    1.12 github.com/golang/protobuf
    

    Requirements

    https://stedolan.github.io/jq/download/
    

    ⏫ Get directly dependent modules that can be upgraded

    Keep your modules updated. Similar function is integrated in VSCode official Go plugin and GoLand.

    go list -u -m $(go list -m -f '{{.Indirect}} {{.}}' all | grep '^false' | cut -d ' ' -f2) | grep '\['
    

    Example

    github.com/goccy/go-json v0.5.1 [v0.7.3]
    github.com/golang/protobuf v1.3.3 [v1.5.2]
    github.com/json-iterator/go v1.1.9 [v1.1.11]
    

    ⏫ Get upstream modules without Go version

    Find outdated modules or imports that you need to upgrade.

    go list -deps -json ./... | jq -rc 'select(.Standard!=true and .Module.GoVersion==null) | .Module.Path' | sort -u
    

    Example

    github.com/facebookgo/clock
    golang.org/x/text
    gopkg.in/yaml.v2
    

    Requirements

    https://stedolan.github.io/jq/download/
    

    ⏫ Get available module versions

    This works even if you did not download or install module locally. This is useful to check to which version you can upgrade to, what is the latest version, and whether there are v2+ major versions recognized by Go toolchain.

    go list -m -versions github.com/google/gofuzz
    

    ⏫ Get go module libyear, number of releases, version delta with go-libyear

    libyear is a simple measure of software dependency freshness. It is a single number telling you how up-to-date your dependencies are. For example Rails 5.0.0 (June 2016) is 1 libyear behind 5.1.2 (June 2017). This tool can also compute number of releases, and version number delta. — @nieomylnieja

    go-libyear /path/to/go.mod
    

    Example

    package                             version  date        latest   latest_date  libyear
    github.com/nieomylnieja/go-libyear           2023-11-06                        2.41
    github.com/pkg/errors               v0.8.1   2019-01-03  v0.9.1   2020-01-14   1.03
    github.com/urfave/cli/v2            v2.20.0  2022-10-14  v2.25.7  2023-06-14   0.67
    golang.org/x/mod                    v0.12.0  2023-06-21  v0.14.0  2023-10-25   0.35
    golang.org/x/sync                   v0.3.0   2023-06-01  v0.5.0   2023-10-11   0.36
    

    Requirements

    go install github.com/nieomylnieja/go-libyear/cmd/go-libyear@latest
    

    ⏫ Make graph of upstream modules with modgraphviz

    For each module, the node representing the greatest version (i.e., the version chosen by Go's minimal version selection algorithm) is colored green. Other nodes, which aren't in the final build list, are colored grey. — official Go team

    go mod graph | modgraphviz | dot -Tsvg -o mod-graph.svg
    

    Requirements

    https://graphviz.org/download/
    go install golang.org/x/exp/cmd/modgraphviz@latest
    

    ⏫ Make graph of upstream packages with import-graph

    Find unexpected dependencies or visualize project. Works best for small number of packages, for large projects use grep to narrow down subgraph. Without -deps only for current module. — @nikolaydubina

    go list -deps -json ./... | jq -c 'select(.Standard!=true) | {from: .ImportPath, to: .Imports[]}' | jsonl-graph | dot -Tsvg > package-graph.svg
    

    Requirements

    https://stedolan.github.io/jq/download/
    https://graphviz.org/download/
    go install github.com/nikolaydubina/import-graph@latest
    go install github.com/nikolaydubina/jsonl-graph@latest
    

    ⏫ Scrape details about upstream modules and make graph with import-graph

    Find low quality or unmaintained dependencies. — @nikolaydubina

    go mod graph | import-graph -i=gomod | jsonl-graph -color-scheme=file://$PWD/basic.json | dot -Tsvg > output.svg
    

    Requirements

    https://graphviz.org/download/
    go install github.com/nikolaydubina/import-graph@latest
    go install github.com/nikolaydubina/jsonl-graph@latest
    

    ⏫ Scrape licenses of upstream dependencies with go-licenses

    Collect all the licenses for checking if you can use the project, for example in proprietary or commercial environment. — Google

    go-licenses csv github.com/gohugoio/hugo
    

    Example

    github.com/cli/safeexec,https://github.com/cli/safeexec/blob/master/LICENSE,BSD-2-Clause
    github.com/bep/tmc,https://github.com/bep/tmc/blob/master/LICENSE,MIT
    github.com/aws/aws-sdk-go,https://github.com/aws/aws-sdk-go/blob/master/LICENSE.txt,Apache-2.0
    github.com/jmespath/go-jmespath,https://github.com/jmespath/go-jmespath/blob/master/LICENSE,Apache-2.0
    github.com/gorilla/websocket,https://github.com/gorilla/websocket/blob/master/LICENSE,BSD-2-Clause
    github.com/pelletier/go-toml/v2,https://github.com/pelletier/go-toml/blob/master/v2/LICENSE,MIT
    github.com/spf13/cobra,https://github.com/spf13/cobra/blob/master/LICENSE.txt,Apache-2.0
    github.com/kyokomi/emoji/v2,https://github.com/kyokomi/emoji/blob/master/v2/LICENSE,MIT
    go.opencensus.io,Unknown,Apache-2.0
    github.com/Azure/azure-storage-blob-go/azblob,https://github.com/Azure/azure-storage-blob-go/blob/master/azblob/LICENSE,MIT
    github.com/yuin/goldmark-highlighting,https://github.com/yuin/goldmark-highlighting/blob/master/LICENSE,MIT
    

    Requirements

    go install github.com/google/go-licenses@latest
    

    ⏫ Explore dependencies with goda

    This tool has extensive syntax for filtering dependencies graphs. It can work with packages and modules. — Egon Elbre

    goda graph . | dot -Tsvg -o graph.svg
    goda graph -cluster -short "github.com/nikolaydubina/go-cover-treemap:all" | dot -Tsvg -o graph.svg
    

    Requirements

    https://graphviz.org/download/
    go install github.com/loov/goda@latest
    

    ⏫ Explore dependencies interactively with spaghetti

    Useful in large refactorings, dependency breaking, physical layout changes. — Alan Donovan, official Go team

    Requirements

    go install github.com/adonovan/spaghetti@latest
    

    ⏫ Explore dependencies graph interactively with modview

    Transform your Go project's dependency graph into a dynamic, interactive visualization with modview. This powerful tool takes the complexity out of your module graph, offering a clear and explorable view of your project's dependencies. — @bayraktugrul

    modview --open
    

    Requirements

    go install github.com/bayraktugrul/modview@latest
    

    ⏫ Explore Go module ecosystem dependency graph interactively with shape-of-go

    A map of the Go module ecosystem containing over 2.6 million modules and 9.4 million declared dependency edges in a single graph. The interactive WebGL viewer visualizes the connected module galaxy with hub and dependent analysis. Live interactive map at shape-of-go.pages.dev. — @LuisLSousa

    ⏫ Explore dependencies graph in CLI with depth

    Use this tool to retrieve and visualize Go source code dependency trees in CLI. You can also visualize multiple packages at once, set max depth, select internal only, and show explanation. — @KyleBanks

    depth github.com/KyleBanks/depth/cmd/depth
    

    Example

    github.com/KyleBanks/depth/cmd/depth
      ├ encoding/json
      ├ flag
      ├ fmt
      ├ io
      ├ log
      ├ os
      ├ strings
      └ github.com/KyleBanks/depth
        ├ fmt
        ├ go/build
        ├ path
        ├ sort
        └ strings
    12 dependencies (11 internal, 1 external, 0 testing).
    

    Requirements

    go install github.com/KyleBanks/depth/cmd/depth@latest
    

    ⏫ Explore your GOPATH with GUI with goggles

    Browse and search local packages. View package documentation. Displays badges for GoDoc, Goreportcard, and Travis.CI (if .travis.yml is present). — @KyleBanks

    goggles
    

    Requirements

    go install github.com/KyleBanks/goggles/cmd/goggles@latest
    

    ⏫ Enforce Go code architecture with go-arch-lint

    Architecture linter. Will check all project import path and compare with arch rules defined in yml file. Useful for hexagonal / onion / ddd / mvc / etc patterns. — @fe3dback

    go-arch-lint
    

    Requirements

    go install github.com/fe3dback/go-arch-lint@latest
    

    ⏫ Check Clean Architecture with go-cleanarch

    Clean architecture validator for go, like a The Dependency Rule and interaction between packages in your Go projects. — @roblaszczak

    go-cleanarch
    

    Requirements

    go install github.com/roblaszczak/go-cleanarch@latest
    

    ⏫ Use go mod directives

    Tell Go compiler which versions of upstreams to include in your build. Tell all users of your module how to deal with versions of your module.

    // Deprecated: use example.com/mod/v2 instead.
    module example.com/mod
    
    go 1.16
    
    require example.com/other/thing v1.0.2
    require example.com/new/thing/v2 v2.3.4
    exclude example.com/old/thing v1.2.3
    replace example.com/bad/thing v1.4.5 => example.com/good/thing v1.4.5
    retract [v1.9.0, v1.9.5]
    

    ⏫ Locally patch dependency with replace

    This can be useful for development. First appeared on blog.

    # clone your dependency to $DEP folder
    # make changes
    go mod edit -replace github.com/google/go-cmp=$DEP
    

    ⏫ Locally patch dependency with go.work

    This is an alternative version may be more robust to accidental mistakes. First appeared on blog.

    # clone your dependency to $DEP folder
    # make changes
    go work init
    go work use . $DEP
    

    Code Visualization

    ⏫ Make C4 diagram with go-structurizr

    This library provides tools to generate C4 diagrams. The process is a bit involved, however you get diagram generated from real Go code automatically. Steps are outlined in blog. — @krzysztofreczek

    Requirements

    manually defining Go main.go script to invoke library
    graphviz
    manual coloring spec (DB, classes)
    

    ⏫ Make graph of function calls with callgraph

    Visualize complex or new project quickly or to study project. Requires main.go in module. Supports Graphviz output format. Has many options for filtering and formatting. — official Go team

    callgraph -format graphviz . | dot -Tsvg -o graph.svg
    recommend: grep <package/class/func of interest>
    recommend: grep -v Error since many packages report error
    recommend: adding `rankdir=LR;` to graphviz file for denser graph
    recommend: you would have to manually fix graphviz file first and last line
    

    Requirements

    go install golang.org/x/tools/cmd/callgraph@latest
    

    ⏫ Make graph of function calls in package with go-callvis

    Quickly track which packages current package is calling and why. — @ofabry

    go-callvis .
    

    Requirements

    go install github.com/ofabry/go-callvis
    

    ⏫ Make PlantUML diagram with goplantuml

    Generates class diagrams in a widely used format with information on structs, interfaces, and their relationships. Render .puml files in, for example, planttext.com. — @jfeliu007

    goplantuml -recursive path/to/gofiles path/to/gofiles2
    

    Requirements

    go get github.com/jfeliu007/goplantuml/parser
    go install github.com/jfeliu007/goplantuml/cmd/goplantuml@latest
    

    ⏫ Make PlantUML diagram with go-plantuml

    Automatically generates visualizations of classes and interfaces for Go packages. We recommend the recursive option. Render .puml files in, for example, planttext.com. — @bykof

    go-plantuml generate -d . -r -o graph.puml