code: func (t *TemplateResource) createStageFile() error {
  	log.Debug("Using source template " + t.Src)
  
  	if !util.IsFileExist(t.Src) {
  		return errors.New("Missing template: " + t.Src)
  	}
  
  	log.Debug("Compiling source template " + t.Src)
  
  	tmpl, err := template.New(filepath.Base(t.Src)).Funcs(t.funcMap).ParseFiles(t.Src)
  	if err != nil {
  		return fmt.Errorf("Unable to process template %s, %s", t.Src, err)
  	}
  
  	// create TempFile in Dest directory to avoid cross-filesystem issues
  	temp, err := ioutil.TempFile(filepath.Dir(t.Dest), "."+filepath.Base(t.Dest))
  	if err != nil {
  		return err
  	}
  
  	if err = tmpl.Execute(temp, nil); err != nil {
  		temp.Close()
  		os.Remove(temp.Name())
  		return err
  	}
  	defer temp.Close()
  
  	// Set the owner, group, and mode on the stage file now to make it easier to
  	// compare against the destination configuration file later.
  	os.Chmod(temp.Name(), t.FileMode)
  	os.Chown(temp.Name(), t.Uid, t.Gid)
  	t.StageFile = temp
  	return nil
  }
docs: // createStageFile stages the src configuration file by processing the src
  // template and setting the desired owner, group, and mode. It also sets the
  // StageFile for the template resource.
  // It returns an error if any.