import ( "fmt" "os" cf "github.com/cloudfoundry/cli/cf/api" ) func main() { orgAPI := cf.NewOrgRepository() currentOrg, err := orgAPI.GetCurrentOrg() if err != nil { fmt.Fprintf(os.Stderr, "Error getting current org name: %s\n", err) os.Exit(1) } fmt.Printf("Current org name: %s\n", currentOrg.Name) }
import ( "fmt" "os" cf "github.com/cloudfoundry/cli/cf/api" ) func main() { orgAPI := cf.NewOrgRepository() newOrg := &cf.Organization{ Name: "my-new-org" } err := orgAPI.Create(newOrg) if err != nil { fmt.Fprintf(os.Stderr, "Error creating new org: %s\n", err) os.Exit(1) } fmt.Printf("Created new org with name: %s\n", newOrg.Name) }These examples use the Cloud Foundry CLI API library (`github.com/cloudfoundry/cli/cf/api`) to interact with the CF system.