» Make grep CLI App in Go » 2. Development » 2.1 Folder Structure

Folder Structure

lr_gorpep/
|
├── LICENSE     # License information
├── README.md   # Project documentation
├── go.mod
├── go.sum
├── internal/   # internal packages
├── main.go     # the main entry point for your application. 
├── internal
└── pkg/        # packages
    └── grep/
        └── search.go

Explanation of each folder/file:

  • pkg/: This directory holds packages (libraries) that are used by your applications.

  • internal/: This directory is for packages that are internal to your project and should not be used by external projects. It helps to encapsulate functionality that is specific to your project.

  • go.mod and go.sum: These files are used for Go modules and dependency management1.

  • README.md: Documentation for your project. It should include information about how to install, configure, and use your CLI app.

  • LICENSE:2 Include a license file that specifies the terms under which your software is distributed.

  • main.go: This is the entry point that users will run from the command line to interact with your tool. It should handle command-line arguments and invoke the functionality provided by your grep/ package.

This structure provides a good separation of concerns and makes it easy to expand your project in the future. You can further break down the grep/ package if your application becomes more complex.

Footnotes

  1. What are go.mod and go.sum in Go?

  2. License file