code: func (cmd *CheckCommand) Run(args ...string) error {
  	// Parse flags.
  	fs := flag.NewFlagSet("", flag.ContinueOnError)
  	help := fs.Bool("h", false, "")
  	if err := fs.Parse(args); err != nil {
  		return err
  	} else if *help {
  		fmt.Fprintln(cmd.Stderr, cmd.Usage())
  		return ErrUsage
  	}
  
  	// Require database path.
  	path := fs.Arg(0)
  	if path == "" {
  		return ErrPathRequired
  	} else if _, err := os.Stat(path); os.IsNotExist(err) {
  		return ErrFileNotFound
  	}
  
  	// Open database.
  	db, err := bolt.Open(path, 0666, nil)
  	if err != nil {
  		return err
  	}
  	defer db.Close()
  
  	// Perform consistency check.
  	return db.View(func(tx *bolt.Tx) error {
  		var count int
  		ch := tx.Check()
  	loop:
  		for {
  			select {
  			case err, ok := <-ch:
  				if !ok {
  					break loop
  				}
  				fmt.Fprintln(cmd.Stdout, err)
  				count++
  			}
  		}
  
  		// Print summary of errors.
  		if count > 0 {
  			fmt.Fprintf(cmd.Stdout, "%d errors found\n", count)
  			return ErrCorrupt
  		}
  
  		// Notify user that database is valid.
  		fmt.Fprintln(cmd.Stdout, "OK")
  		return nil
  	})
  }
docs: // Run executes the command.