JavaRush
AI Academy
new
Promotion
Learning
Courses
Tasks
Quizzes
Games
Help
Schedule of nudges
Internship
Community
Users
Forum
Chat
Articles
Activities
Reviews
Subscriptions
Light theme

Lectures

  • Reviews
  • About us
  • CS50
Start
Start learning
Start learning
  • My progress
  • Courses
  • Quest map
  • Lectures
  • flag.FlagSet: separate flags per command

    Go SELF
    49 level,0 lecture
    We break down how to build a CLI with subcommands in Go using flag.FlagSet: separate flags for each command, isolated parsing, error control via flag.ContinueOnError, output configuration via SetOutput, and a custom Usage. At the end, we cover common mistakes when using FlagSet and how to avoid them.
    Open
  • Dispatcher pattern: app <cmd> [flags]

    Go SELF
    49 level,1 lecture
    We break down a convenient CLI approach: “subcommands instead of a mode flag”. The launch format is app <cmd> [flags] [args], the dispatcher’s role (routing), extracting the command from os.Args, minimal routing via switch, and a scalable option via a map[ string] handler table. We also pin down the responsibility boundary: the dispatcher chooses the command, while flags are parsed by the command itself (no global flag.Parse()), and we improve UX with usage and clear errors.
    Open
  • Parsing positional arguments and parsing errors

    Go SELF
    49 level,2 lecture
    We cover how to correctly read positional arguments in a Go CLI via fs.Parse ( argv ) and the methods fs.Args(), fs.NArg(), fs.Arg(i); why you should not work with the “raw” argv; how to design a strict command contract ( 0, 1, N arguments); how to parse types via strconv.Atoi; and how to return meaningful usage errors with the ErrUsage marker and the %w wrapper.
    Open
  • Exit codes: the 0/1/2 contract for CLI

    Go SELF
    49 level,3 lecture
    We break down why CLI apps need a stable exit-code contract 0/ 1/ 2, how to separate “invalid invocation” errors from runtime errors via the sentinel ErrUsage and errors.Is, why os.Exit “breaks” defer, and how to build an architecture with a single exit point: run returns error, and the top level prints diagnostics to stderr and maps errors to an exit code.
    Open
  • Error handling in a CLI: details in the error chain and in logs

    Go SELF
    49 level,4 lecture
    We break down a practical approach to errors in a Go CLI: how to separate a short user-facing message from the technical cause in the error chain, print an error exactly once at the application boundary, assign exit codes (
    0
    /
    1
    /
    2
    ) consistently via errors.Is and the ErrUsage marker, and how to carefully extract causes for diagnostics (a debug chain) without “wall-of-text” output.
    Open
Learn
  • Registration
  • Java course
  • Help with tasks
  • Pricing
Community
  • Users
  • Articles
  • Forum
  • Chat
  • Activities
Company
  • About us
  • Contacts
  • Reviews
  • FAQ
  • Support
JavaRushJavaRush — is an interactive online course for learning Java programming from scratch. It contains 1200 practical tasks with one-click solution checking, the necessary minimum of theory on Java basics, and motivating features that help you complete the course: games, quizzes, interesting projects and articles on effective learning and the career of a Java developer.
Follow us
Язык интерфейса
Русский
English
Українська
"Programmers are not born" © 2026 JavaRush
MastercardVisa
"Programmers are not born" © 2026 JavaRush