code: func (uw *UnitWriter) WriteUnit(path string, errmsg string, opts ...*unit.UnitOption) {
  	if uw.err != nil {
  		return
  	}
  
  	file, err := os.OpenFile(path, os.O_WRONLY|os.O_CREATE|os.O_TRUNC, 0644)
  	if err != nil {
  		uw.err = errwrap.Wrap(errors.New(errmsg), err)
  		return
  	}
  	defer file.Close()
  
  	if _, err = io.Copy(file, unit.Serialize(opts)); err != nil {
  		uw.err = errwrap.Wrap(errors.New(errmsg), err)
  		return
  	}
  	if err := user.ShiftFiles([]string{path}, &uw.p.UidRange); err != nil {
  		uw.err = errwrap.Wrap(errors.New(errmsg), err)
  		return
  	}
  }
docs: // WriteUnit writes a systemd unit in the given path with the given unit options
  // if no previous error occurred.