# Create a CLI to display in the terminal in Go

日本語版: 日本語で読む

Table of Contents

I wrote in [June 2025] Looks like this year is half over that I didn’t have anything to develop on my own, but now that I have something I want to make, I decided to start working on it.

What I want to create is something like a business card for an engineer whose profile can be displayed using the npx xxxx command using the CLI tool.

Apparently it was popular in the past, but I didn’t know about it.

I heard that someone was working on podcast, which I heard the other day, and I wanted to make one myself.

It seems easier to develop with TypeScript, but I decided to use go.

Hello World in terminal with Go

I had made something like api with go in the past, but I didn’t remember anything about it, so I started almost from scratch.

Manage modules with go mod init

First

Terminal window
go mod init github.com/xxxxxxxxxx

Start module management with .

Something like package.json for node. It does not have the functionality that script has in package.json.

By the way, it seems that the github.com/xxxxxxxxxx part can be a repository that does not exist, or it can be named something like myproject.

However, if you plan to eventually publish it, it is best practice to match the path to the repository where you will actually publish it.

Display a specific string in the terminal when running the build file

next

package main
import "fmt"
func main() {
fmt.Println("Hello, World!")
}

Create a code called main.go.

“ bash o build -o hello-world main.go

最後に上記のようにビルドすると`hello-world`というファイルが同階層にアウトプットされる。
``` bash
./hello-world

で、ターミナルにHello Worldと表示される。


More Posts
My avatar

Thanks for reading my blog post! Feel free to check out my other posts or contact me via the social links in the footer.


Comments