stack.go
func (s *Stack) Peak() (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
	}
	return header, data, nil
}
func (s *Stack) Peak() (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
	}
	return header, data, nil
}
func ( s * Stack ) Peak ( ) ( 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 } return header , data , nil }
// Peak of stack - get one segment from stack but not remove
Peak of stack - get one segment from stack but not remove