July 2019
Intermediate to advanced
458 pages
12h 12m
English
The next step is to persist the status between sessions, and this requires some action to be executed when the application starts and another one to be executed when the application ends. These new behaviors could be integrated with some changes on the command interface:
type Command interface { Startup() error Shutdown() error GetName() string GetHelp() string Run(r io.Reader, w io.Writer, args ...string) (exit bool)}
The Startup() method is responsible for the status and loading it when the application starts, and the Shutdown() method needs to save the current status to the disk before exit. We can update the Base structure with these methods; however, this will not do anything, because there's no status:
// Startup does ...
Read now
Unlock full access