DEV Community

Junya Uchizono
Junya Uchizono

Posted on

Introducing Mimi: A CLI Tool for Managing Dependencies in Go Projects

Hello everyone,

In this post, I'd like to introduce a CLI tool that I developed for analyzing and controlling direct and indirect package dependencies in Go projects, and for visualizing these dependencies.

What I've Built

https://github.com/junyaU/mimi
Feel free to star it 🌟
※By the way, the name "mimi" is taken from my pet dog's name🐶.

You can specify the path in the Go project and set the thresholds for the number of packages that can directly and indirectly depend on it. If there are packages that exceed the dependency threshold, the tool will output the package names and the number of dependencies that exceed the threshold.
You can also output the results in a table format, or list them all.

Why I Made It

Go is loved by many developers for its performance and safety when developing projects. However, as projects grow larger (and this is not limited to Go), dependency relationships tend to become more complicated.

The increase in dependencies can reduce the readability and maintainability of the code, and can also become a barrier when new developers join the project. To avoid these issues, it is necessary to regularly check and manage the dependency relationships in the project before these problems arise. However, this can be a tedious and complex task to do manually.

Therefore, I decided to create mimi to:

  • Control the complexity of dependencies (I want to include complexity checks in CI/CD)
  • Clearly display the relationship between direct and indirect dependencies to make management easier

Features

The main goal of this tool is to assist in managing dependency relationships in Go projects. Specifically, it quantifies the direct and indirect dependencies of Go packages and provides a function to list them.

Currently, the following commands are available:

  • check: Checks whether the direct and indirect dependencies of the given package exceed the specified thresholds
  • table: Displays the direct and indirect dependencies of the given Go package in table format
  • list: Lists all dependencies of the given Go package
  • run: Reads a yaml file and executes the commands defined in it

By using these commands, you can grasp the dependency relationships of the project at a glance and identify areas where the dependencies are becoming complex. Also, by setting a threshold for the dependencies, a warning is displayed when the dependencies exceed the threshold.

How to Use It

Here's a quick overview of how to use it. For a more detailed explanation, please check out the README.

First, install it:

$ go get -u github.com/junyaU/mimi
$ go install github.com/junyaU/mimi
Enter fullscreen mode Exit fullscreen mode

Here are some sample uses of the commands:

check

Checks whether the direct and indirect dependencies of the specified Go package exceed the set threshold.

$ mimi check <package_path> --direct=<direct_threshold> --indirect=<indirect_threshold> --depth=<depth_threshold>
Enter fullscreen mode Exit fullscreen mode

Image description

table

Displays the direct and indirect dependencies of the specified Go package in table format. Packages that exceed the threshold are displayed in red.

$ mimi table <package_path> --direct=<direct_threshold> --indirect=<indirect_threshold> --depth=<depth_threshold>
Enter fullscreen mode Exit fullscreen mode

Image description

list

Lists all dependencies of the specified Go package.

$ mimi list <package_path>
Enter fullscreen mode Exit fullscreen mode

Image description

run

Reads the configuration yaml file and executes the commands defined in it.

$ mimi run <config_file_path>
Enter fullscreen mode Exit fullscreen mode

yaml

version: 1.0
commands:
  - name: check
    parameters:
      path: ./testdata/layer/domain/model
      directThreshold: 2
      indirectThreshold: 3
      depthThreshold: 3
  - name: check
    parameters:
      path: ./testdata/layer/domain/model/flow
      directThreshold: 5
      indirectThreshold: 2
  - name: table
    parameters:
      path: ./testdata/layer/domain/model
      directThreshold: 3
      indirectThreshold: 5
  - name: list
    parameters:
      path: ./testdata/layer/domain/model/flow
Enter fullscreen mode Exit fullscreen mode

Summary

I've introduced the CLI tool, "Mimi," which measures and manages Go package dependencies. The tool is still in the early stages of development and I have many more features planned. By integrating Mimi into your CI/CD process, you can easily manage the complexity of your Go projects and maintain high-quality, manageable code. Your feedback and contributions to the project are welcome, as they will help to improve the tool and make it more useful for everyone.

Please visit the project's GitHub repository, give it a star if you find it interesting, and consider contributing if you're able. I look forward to seeing how the project evolves with your support and feedback.

Thank you for taking the time to learn about Mimi and I hope you find it useful in your Go projects!

Top comments (0)