code: func realMain() error {
  	// Setup logging.
  	backendLogger := btclog.NewBackend(os.Stdout)
  	defer os.Stdout.Sync()
  	log = backendLogger.Logger("MAIN")
  	dbLog := backendLogger.Logger("BCDB")
  	dbLog.SetLevel(btclog.LevelDebug)
  	database.UseLogger(dbLog)
  
  	// Setup the parser options and commands.
  	appName := filepath.Base(os.Args[0])
  	appName = strings.TrimSuffix(appName, filepath.Ext(appName))
  	parserFlags := flags.Options(flags.HelpFlag | flags.PassDoubleDash)
  	parser := flags.NewNamedParser(appName, parserFlags)
  	parser.AddGroup("Global Options", "", cfg)
  	parser.AddCommand("insecureimport",
  		"Insecurely import bulk block data from bootstrap.dat",
  		"Insecurely import bulk block data from bootstrap.dat.  "+
  			"WARNING: This is NOT secure because it does NOT "+
  			"verify chain rules.  It is only provided for testing "+
  			"purposes.", &importCfg)
  	parser.AddCommand("loadheaders",
  		"Time how long to load headers for all blocks in the database",
  		"", &headersCfg)
  	parser.AddCommand("fetchblock",
  		"Fetch the specific block hash from the database", "",
  		&fetchBlockCfg)
  	parser.AddCommand("fetchblockregion",
  		"Fetch the specified block region from the database", "",
  		&blockRegionCfg)
  
  	// Parse command line and invoke the Execute function for the specified
  	// command.
  	if _, err := parser.Parse(); err != nil {
  		if e, ok := err.(*flags.Error); ok && e.Type == flags.ErrHelp {
  			parser.WriteHelp(os.Stderr)
  		} else {
  			log.Error(err)
  		}
  
  		return err
  	}
  
  	return nil
  }
docs: // realMain is the real main function for the utility.  It is necessary to work
  // around the fact that deferred functions do not run when os.Exit() is called.