A template for creating console applications on go using TUI
Made using data from packages:
- Cobra - Library for creating powerful modern CLI applications
- Fang - The CLI starter kit
- Huh - A simple interactive forms and prompts in the terminal
What do you get:
clone the repository
git clone https://github.com/deniskorbakov/skeleton-cli-go.gitgo to the project folder
cd skeleton-cli-gobuild the app
make buildlaunch the app
./cliIn order to reuse the project for your application, you need to replace the following items
Change the path to the cli to the name of your utility cmd/cli -> cmd/your_name_cli
In the .goreleaser.yaml file, you need to change the name of the cli to your utility
version: 2
env:
- GO111MODULE=on
project_name: your_name_cliChange the application name in the Makefile
build:
go mod vendor
go build -ldflags "-w -s" -o your_name_cli cmd/your_name_cli/main.goChange the application description in the root command - configs/constname/root.go
Commands are created in the directory - internal/command
We are creating a file based on the example of the file - internal/command/example.go
After creation, add the command to internal/command/root.go
package command
func Run() {
// Other code
cmd.AddCommand(
exampleCmd,
// Add new comments here
)
}configs/constname - This directory contains files for the names of commands, their descriptions, etc.
You can add or change team data in this space
The components use huh
The components in the application are located here - internal/component
These components can be either a form or a separate element of it - further logic depends on your needs
I described the standard example in the file - internal/component/form
We divide the logic into the form itself and what it outputs in a separate structure with fields that it returns
The application also uses the internal/component/output/output.go component. It is designed to display text in
different colors
The app receives the version during the build using Goreleaser
The version that you specified in the repository when creating the new release will be installed
The release is being assembled with the help of Goreleaser
You can see exactly what is going on here - .goreleaser.yaml
the project has golangci-lint which adjusts your code
to launch it, specify - make lint
Jobs are configured here to check the quality of the code through lint and also add binary files of your application for different OS
In order for the job release to work, you need to specify the GH token in the certificates of your project
The secret should be called - GO_RELEASER
We appreciate your support and look forward to making our product even better with your help!

