code: func (l *LogFile) Rotate() error {
  	// rename dest file if it already exists.
  	if _, err := os.Stat(l.name); err == nil {
  		name := l.name + "." + time.Now().Format(time.RFC3339)
  		if err = os.Rename(l.name, name); err != nil {
  			return err
  		}
  	}
  	// create new file.
  	file, err := os.Create(l.name)
  	if err != nil {
  		return err
  	}
  	// switch dest file safely.
  	l.mu.Lock()
  	file, l.file = l.file, file
  	l.mu.Unlock()
  	// close old file if open.
  	if file != nil {
  		if err := file.Close(); err != nil {
  			return err
  		}
  	}
  	return nil
  }
docs: // Rotate renames old log file, creates new one, switches log and closes the old file.