Categorygithub.com/cloud-gov/go-cfenv
modulepackage
1.19.1
Repository: https://github.com/cloud-gov/go-cfenv.git
Documentation: pkg.go.dev

# README

Go CF Environment Package

Overview

cfenv is a package to assist you in writing Go apps that run on Cloud Foundry. It provides convenience functions and structures that map to Cloud Foundry environment variable primitives (http://docs.cloudfoundry.org/devguide/deploy-apps/environment-variable.html).

Usage

go get github.com/cloud-gov/go-cfenv

package main

import (
	"github.com/cloud-gov/go-cfenv"
)

func main() {
	appEnv, _ := cfenv.Current()

	fmt.Println("ID:", appEnv.ID)
	fmt.Println("Index:", appEnv.Index)
	fmt.Println("Name:", appEnv.Name)
	fmt.Println("Host:", appEnv.Host)
	fmt.Println("Port:", appEnv.Port)
	fmt.Println("Version:", appEnv.Version)
	fmt.Println("Home:", appEnv.Home)
	fmt.Println("MemoryLimit:", appEnv.MemoryLimit)
	fmt.Println("WorkingDir:", appEnv.WorkingDir)
	fmt.Println("TempDir:", appEnv.TempDir)
	fmt.Println("User:", appEnv.User)
	fmt.Println("Services:", appEnv.Services)
}

Contributing

Pull requests welcomed.

# Functions

Current creates a new App with the current environment; returns an error if the current environment is not a Cloud Foundry environment.
CurrentEnv translates the current environment to a map[string]string.
Env translates the provided environment to a map[string]string.
IsRunningOnCF returns true if the current environment is Cloud Foundry and false if it is not Cloud Foundry.
New creates a new App with the provided environment.

# Structs

An App holds information about the current app running on Cloud Foundry.
No description provided by the author
Service describes a bound service.

# Type aliases

Services is an association of service labels to a slice of services with that label.