A help message describes how to use a command-line tool: its flags, argument types, defaults, required inputs, and invocation syntax. It guides users toward valid commands and reduces the need for separate error-handling text. section 4.1.1 section 4.3.2
A useful help message can communicate:
- Available options such as URL, request count, concurrency, and requests per second. section 4.1.1
- Flag types, sensible defaults, and required values generated from flag definitions. section 4.3.2
- The distinction between optional flags and required positional arguments, such as `usage: hit [options] url`. section 4.5.3
For a first version, a program can store multiline help text in a raw string literal and print it with the logo. Once parsing moves to a `flag.FlagSet`, the standard library can generate usage output from registered flags and handle parsing errors. Assigning `FlagSet.Usage` enables a custom header and positional-argument description; write through `FlagSet.Output()` so help and errors use the same destination. section 4.1.1 section 4.5.2 section 4.3.2
A positional URL with optional flags
Running `hit -h` can produce `usage: hit [options] url`, followed by `-c`, `-n`, and `-rps` with descriptions and defaults. A command such as `hit -c 2 -n 100 https://github.com/inancgumus` combines optional flags with the required URL. section 4.5.3
Listing 4.1 Printing usage (hit/cmd/hit/hit.go)
package main
import "fmt"
const logo = ` #1
__ __ __ ______
/\ \_\ \ /\ \ /\__ _\
\ \ __ \ \ \ \ \/_/\ \/
\ \_\ \_\ \ \_\ \ \_\
\/_/\/_/ \/_/ \/_/` #1
const usage = ` #1
Usage:
-url
HTTP server URL (required)
-n
Number of requests
-c
Concurrency level
-rps
Requests per second` #1
func main() {
fmt.Printf("%s\n%s", logo, usage)
}
View a complete runnable starting point that prints a logo and a multiline usage message. section 4.1.1

