stack.go
func (s *Stack) Pop() (header, data []byte, err error) {
	if s.depth == 0 {
		return nil, nil, nil
	}
	s.guard.Lock()
	defer s.guard.Unlock()
	s.lastAccess = time.Now()
	file, err := s.getFile()
	if err != nil {
		return nil, nil, err
	}
	data = make([]byte, s.currentBlock.DataSize)
	header = make([]byte, s.currentBlock.HeaderSize)
	// Read header
	_, err = file.ReadAt(header, int64(s.currentBlock.HeaderPoint))
	if err != nil {
		return nil, nil, err
	}
	// Read data
	_, err = file.ReadAt(data, int64(s.currentBlock.DataPoint))
	if err != nil {
		return nil, nil, err
	}
	// Read new block if current block is not head
	var newBlock fileBlock
	if s.currentBlockPos != 0 {
		newBlock, err = readBlockAt(file, int64(s.currentBlock.PrevBlock))
		if err != nil {
			return nil, nil, err
		}
	}
	// Remove tail
	err = file.Truncate(int64(s.currentBlockPos))
	if err != nil {
		return nil, nil, err
	}
	s.depth--
	s.currentBlockPos = int64(s.currentBlock.PrevBlock)
	s.currentBlock = newBlock

	return header, data, nil
}
func (s *Stack) Pop() (header, data []byte, err error) {
	if s.depth == 0 {
		return nil, nil, nil
	}
	s.guard.Lock()
	defer s.guard.Unlock()
	s.lastAccess = time.Now()
	file, err := s.getFile()
	if err != nil {
		return nil, nil, err
	}
	data = make([]byte, s.currentBlock.DataSize)
	header = make([]byte, s.currentBlock.HeaderSize)
	// Read header
	_, err = file.ReadAt(header, int64(s.currentBlock.HeaderPoint))
	if err != nil {
		return nil, nil, err
	}
	// Read data
	_, err = file.ReadAt(data, int64(s.currentBlock.DataPoint))
	if err != nil {
		return nil, nil, err
	}
	// Read new block if current block is not head
	var newBlock fileBlock
	if s.currentBlockPos != 0 {
		newBlock, err = readBlockAt(file, int64(s.currentBlock.PrevBlock))
		if err != nil {
			return nil, nil, err
		}
	}
	// Remove tail
	err = file.Truncate(int64(s.currentBlockPos))
	if err != nil {
		return nil, nil, err
	}
	s.depth--
	s.currentBlockPos = int64(s.currentBlock.PrevBlock)
	s.currentBlock = newBlock

	return header, data, nil
}
// Pop one segment from tail of stack. Returns nil,nil,nil if depth is 0