code: func (s *LocalState) RefreshState() error {
  	s.mu.Lock()
  	defer s.mu.Unlock()
  
  	if s.PathOut == "" {
  		s.PathOut = s.Path
  	}
  
  	var reader io.Reader
  
  	// The s.Path file is only OK to read if we have not written any state out
  	// (in which case the same state needs to be read in), and no state output file
  	// has been opened (possibly via a lock) or the input path is different
  	// than the output path.
  	// This is important for Windows, as if the input file is the same as the
  	// output file, and the output file has been locked already, we can't open
  	// the file again.
  	if !s.written && (s.stateFileOut == nil || s.Path != s.PathOut) {
  		// we haven't written a state file yet, so load from Path
  		f, err := os.Open(s.Path)
  		if err != nil {
  			// It is okay if the file doesn't exist, we treat that as a nil state
  			if !os.IsNotExist(err) {
  				return err
  			}
  
  			// we need a non-nil reader for ReadState and an empty buffer works
  			// to return EOF immediately
  			reader = bytes.NewBuffer(nil)
  
  		} else {
  			defer f.Close()
  			reader = f
  		}
  	} else {
  		// no state to refresh
  		if s.stateFileOut == nil {
  			return nil
  		}
  
  		// we have a state file, make sure we're at the start
  		s.stateFileOut.Seek(0, io.SeekStart)
  		reader = s.stateFileOut
  	}
  
  	state, err := terraform.ReadState(reader)
  	// if there's no state we just assign the nil return value
  	if err != nil && err != terraform.ErrNoState {
  		return err
  	}
  
  	s.state = state
  	s.readState = s.state.DeepCopy()
  	return nil
  }
docs: // StateRefresher impl.