profile

package
v0.0.0-...-82e7740 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 18, 2019 License: MIT Imports: 1 Imported by: 6

README

comm-profile GoDoc

profile library for Go

Installation

go get gopkg.in/goyy/goyy.v0/comm/profile

Documentation

Overview

Package profile implements profile utility functions.

Usage

profile.Actives()
profile.SetActives(profile.PROD, profile.TEST)
profile.Accepts(profile.PROD, profile.DEV)
profile.Accepts("tmp", "!development")

Index

Examples

Constants

View Source
const (
	// PROD is the production active
	PROD = "production"
	// DEV is the development active
	DEV = "development"
	// TEST is the test active
	TEST = "test"
	// UNIT is the unit active
	UNIT = "unit"
	// ADM is the adm active
	ADM = "adm"
	// WEB is the web active
	WEB = "web"
	// WAP is the wap active
	WAP = "wap"
	// API is the api active
	API = "api"
	// QRY is the qry active
	QRY = "qry"
)

Variables

This section is empty.

Functions

func Accepts

func Accepts(profiles ...string) bool

Accepts return whether one or more of the given profiles is active or, in the case of no explicit active profiles, whether one or more of the given profiles is included in the set of default profile. If a profile begins with '!' the logic is inverted, i.e. the method will return true if the given profile is not active. For example, profile.Accepts("p1", "!p2") will return true if profile 'p1' is active or 'p2' is not active.

func Actives

func Actives() []string

Actives return the set of profiles explicitly made active for this environment. Profiles are used for creating logical groupings of bean definitions to be registered conditionally, for example based on deployment environment. Profiles can be activated by calling profile.SetActives(...string). If no profiles have explicitly been specified as active, then default profile will automatically be activated.

Example
package main

import (
	"fmt"

	"gopkg.in/goyy/goyy.v0/comm/profile"
)

func main() {
	profile.SetActives(profile.PROD, profile.TEST)
	fmt.Println(profile.Accepts(profile.PROD))
	fmt.Println(profile.Accepts(profile.DEV))
	fmt.Println(profile.Actives())

}
Output:

true
false
[production test]

func Default

func Default() string

Default return the set of profiles explicitly made active for this environment. Profiles are used for creating logical groupings of bean definitions to be registered conditionally, for example based on deployment environment. Profiles can be activated by calling profile.SetDefault(string). If no profiles have explicitly been specified as active, then default profile will automatically be activated.

func SetActives

func SetActives(profiles ...string)

SetActives set the actives.

func SetDefault

func SetDefault(profile string)

SetDefault set the default active.

Types

This section is empty.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL