motd

2026-06-04

motd (message of the day) is an oldie often used by sysadmin to display a greeting message upon a successful login. I wrote a Go project[1] which is both a motd library (which you can import) and a command line tool (which you can run). Here is the Go project structure:

/home/david/dev/motd
├── README
├── cmd
│   └── motd_cli
│       └── main.go
├── go.mod
├── motd.go
└── motd.txt

To use it as a library, import it and call motd.Next():

import "github.com/davidfung/motd"

To use it as a command line tool:

$ go install github.com/davidfung/motd/cmd/motd_cli@latest
$ motd_cli

It is a good convention to put each command line tool in a separate folder under a "cmd" folder at the project root. Each subfolder in the "cmd" folder is a Go package. Since all these Go packages belong to the same Go module, there is no need to have a separate go.mod file for each of the them.

Remember:

  1. A Go project is called a module.
  2. A Go module is for code distribution.
  3. A Go package is for code reuse.

Reference

  1. https://github.com/davidfung/motd


Index