A toy repo used to test the functionality of "go mod why".

Mod Why Test

Discussion

From a module perspective:

The main module (github.com/ejweber/mod-why-test) has a single direct dependency (github.com/ejweber/mod-why-test/direct-mod). This direct dependency has two transitive dependencies (github.com/ejweber/mod-why-test/transitive-used-mod and github.com/ejweber/mod-why-test/transitive-unused-mod).

github.com/ejweber/mod-why-test 
|-- github.com/ejweber/mod-why-test/direct 
    |-- github.com/ejweber/mod-why-test/transitive-used-mod 
    |-- github.com/ejweber/mod-why-test/transitive-unused-mod

From a package perspective:

The main package imports only one package (github.com/ejweber/mod-why-test/direct-mod/direct-used-pkg). That package imports only one package (github.com/ejweber/mod-why-test/transitive-used-mod/transitive-used-pkg).

github.com/ejweber/mod-why-test/main
|-- github.com/ejweber/mod-why-test/direct-mod/direct-used-pkg
    |-- github.com/ejweber/mod-why-test/transitive-used-mod/transitive-used-pkg

github.com/ejweber/mod-why-test/transitive-unused-mod DOES appear in the module dependency graph (because it is a direct dependency of the main module's direct dependency).

--> go mod graph
mod-why-test github.com/ejweber/mod-why-test/[email protected]
github.com/ejweber/mod-why-test/[email protected] github.com/ejweber/mod-why-test/[email protected]
github.com/ejweber/mod-why-test/[email protected] github.com/ejweber/mod-why-test/[email protected]

However, github.com/ejweber/mod-why-test/transitive-unused-mod is NOT actually a transitive dependency of the main module, because absolutely none of its code is involved in the build of the main modules packages.

"go mod why -m all" recognizes that github.com/ejweber/mod-why-test/transitive-unused-mod is NOT actually required, but that github.com/ejweber/mod-why-test/transitive-used-mod IS required:

--> go mod why -m all
# mod-why-test
mod-why-test

# github.com/ejweber/mod-why-test/direct-mod
mod-why-test
github.com/ejweber/mod-why-test/direct-mod/direct-used-pkg

# github.com/ejweber/mod-why-test/transitive-unused-mod
(main module does not need module github.com/ejweber/mod-why-test/transitive-unused-mod)

# github.com/ejweber/mod-why-test/transitive-used-mod
mod-why-test
github.com/ejweber/mod-why-test/direct-mod/direct-used-pkg
github.com/ejweber/mod-why-test/transitive-used-mod/transitive-used-pkg

"go mod why all" recognizes that none of the packages from github.com/ejweber/mod-why-test/transitive-unused-mod are required but that packages from github.com/ejweber/mod-why-test/transitive-used-mod ARE required:

--> go mod why all
# github.com/ejweber/mod-why-test/direct-mod/direct-used-pkg
mod-why-test
github.com/ejweber/mod-why-test/direct-mod/direct-used-pkg

# github.com/ejweber/mod-why-test/transitive-used-mod/transitive-used-pkg
mod-why-test
github.com/ejweber/mod-why-test/direct-mod/direct-used-pkg
github.com/ejweber/mod-why-test/transitive-used-mod/transitive-used-pkg

# mod-why-test
mod-why-test

Conclusion

github.com/ejweber/mod-why-test/transitive-unused-mod should NOT be considered a transitive dependency of the main module. github.com/ejweber/mod-why-test/transitive-used-mod SHOULD be considered a transitive dependency of the main module. "go mod why -m all" is capable of correctly making this determination.

Owner
Eric Weber
Solutions software engineer for NetApp E-Series Group
Eric Weber
Similar Resources

Orkestra Workflow Executor Template Repo

Orkestra Workflow Executor Template Repo This is a template repository for a new workflow executor Usage Generate your repository from this template b

Nov 9, 2021

OpenFunction Sample Repo

OpenFunction Samples Installation Version OpenFunction v0.4.0 Setup a Cluster minikube start -p demo --kubernetes-version=v1.22.2 --network-plugin=cni

Apr 20, 2022

To get json about repo&pkg relationship

pkg_repo_tool 1. Usage 把从 frameworks 收集到的 bp 文件放到一个文件夹中。在这里为了方便叙述,就把这个文件夹命名为 frameworks 并且放在 bprepo2json/main 之下。 然后: cd bprepo2json/main go run .

Jan 11, 2022

Repo Tugas Problem Solving Paradigm (Greedy, D&C, Dynamic Programming) ALTA Immersive BE5

Repo Tugas Problem Solving Paradigm (Greedy, D&C, Dynamic Programming) ALTA Immersive BE5

Cara mengerjakan tugas clone project ini, melalui git clone https://github.com/ALTA-Immersive-BE5/Problem-Solving-Paradigm.git setelah clone selesai,

Dec 23, 2021

Beecrowd is a Jugde Online Plataform to problems submissions. This repo contains all my submissions to Beecrowd.

Beecrowd Solutions Keywords: Beecrowd, judge, problems, competitive, programming, solutions, ad-hoc, sql, strings, algorithms, math, graphs Table of C

Jan 5, 2022

Script to generate a web page for your Aliucord plugins repo.

Aliucord-Store Script used to generate a website front-end for your plugins. Usage: go run cmds/store/main.go -dir string Your repository's

Jan 31, 2022

James is your butler and helps you to create, build, debug, test and run your Go projects

James is your butler and helps you to create, build, debug, test and run your Go projects

go-james James is your butler and helps you to create, build, debug, test and run your Go projects. When you often create new apps using Go, it quickl

Oct 8, 2022

Enrich `go test` outputs with text decorations.

Enrich `go test` outputs with text decorations.

richgo Rich-Go will enrich go test outputs with text decorations Installation (go get): go get -u github.com/kyoh86/richgo (homebrew): brew tap kyoh8

Dec 28, 2022

Automatically generate Go test boilerplate from your source code.

Automatically generate Go test boilerplate from your source code.

gotests gotests makes writing Go tests easy. It's a Golang commandline tool that generates table driven tests based on its target source files' functi

Jan 3, 2023
Go binding to libserialport for serial port functionality.

Go Serial Package serial provides a binding to libserialport for serial port functionality. Serial ports are commonly used with embedded systems, such

Nov 1, 2022
Quick and dirty demo of cobra functionality

Cobra Demo Purpose Testing out how cobra CLI's are parsed. Overview To use this repo, you can run something like this (from the directory where you cl

Sep 26, 2022
Create one endpoint with add user functionality

hubuc-task Create one endpoint with add user functionality

Nov 13, 2021
Toy program for benchmarking safe and unsafe ways of saving a file

save-a-file benchmarks the many strategies an editor could use to save a file. Example output on a SSD: ext4: $ ./save-a-file ~/tmp/foo 29.195µs per s

Jan 4, 2023
A toy language parser, lexer and interpreter written in Golang

Monkey - A toy programming language Monkey is a toy programming language used to learn how to write a lexer, parser and interpreter. The language is i

Nov 16, 2021
Implement a toy in-memory store information service for a delivery company

Implement a toy in-memory store information service for a delivery company

Nov 22, 2021
A toy project like cowsay or ponysay
A toy project like cowsay or ponysay

xkcdsay is a simple application just for fun. Once again, Just for fun. I like c

Dec 23, 2022
Hack this repo and add your name to the list above. Creativity and style encouraged in both endeavors.

Hack this repo and add your name to the list above. Creativity and style encouraged in both endeavors.

Oct 1, 2021
Auto-updating F-Droid repo using GitHub Actions
Auto-updating F-Droid repo using GitHub Actions

fdroid This repository hosts an F-Droid repo for my apps. This allows you to install and update apps very easily. How to use At first, you should inst

Dec 29, 2022
Monitor star changes of GitHub repo, and send the notification to slack or lark.

stargazers Features monitor the star events of the GitHub repo send the notifications to Slack or Lark How to use For Lark, create a bot called like s

Dec 4, 2022