import ( "github.com.cloudfoundry.cli.cf/errors" "github.com.cloudfoundry.cli.cf/requirements" ) func deleteApp() error { reqFactory := requirements.NewFactory(nil) spaceReq := reqFactory.NewTargetedSpaceRequirement("production") err := spaceReq.Execute() if err != nil { return errors.New("Unable to delete app: %s", err) } // Delete the app here... return nil }
import ( "github.com.cloudfoundry.cli.cf/errors" "github.com.cloudfoundry.cli.cf/requirements" ) func deployApp() error { reqFactory := requirements.NewFactory(nil) spaceReq := reqFactory.NewTargetedSpaceRequirement("staging") err := spaceReq.Execute() if err != nil { return errors.New("Unable to deploy app: %s", err) } // Deploy the app here... return nil }In this example, the `deployApp` function uses the `NewTargetedSpaceRequirement` to check if the current space is set to "staging" before deploying the app. If the space is not set correctly, an error is returned. Overall, the `NewTargetedSpaceRequirement` requirement is a useful tool for ensuring that tasks are executed only in the correct target space.