code: func (db *db) View(fn func(database.Tx) error) error {
  	// Start a read-only transaction.
  	tx, err := db.begin(false)
  	if err != nil {
  		return err
  	}
  
  	// Since the user-provided function might panic, ensure the transaction
  	// releases all mutexes and resources.  There is no guarantee the caller
  	// won't use recover and keep going.  Thus, the database must still be
  	// in a usable state on panics due to caller issues.
  	defer rollbackOnPanic(tx)
  
  	tx.managed = true
  	err = fn(tx)
  	tx.managed = false
  	if err != nil {
  		// The error is ignored here because nothing was written yet
  		// and regardless of a rollback failure, the tx is closed now
  		// anyways.
  		_ = tx.Rollback()
  		return err
  	}
  
  	return tx.Rollback()
  }
docs: // View invokes the passed function in the context of a managed read-only
  // transaction with the root bucket for the namespace.  Any errors returned from
  // the user-supplied function are returned from this function.
  //
  // This function is part of the database.DB interface implementation.