info

package
v1.0.65 Latest Latest
Warning

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

Go to latest
Published: Sep 3, 2022 License: MIT Imports: 7 Imported by: 0

Documentation

Overview

Provides various information about the current runtime of the application

Index

Constants

View Source
const (
	// ProfileDebug is the default Profile intended to be used when developing the app.
	ProfileDebug = iota

	// ProfileTest is the Profile intended to be used in unit tests.
	ProfileTest

	// ProfileRelease is the Profile intended to be enabled when the app is distributed in its binary form.
	ProfileRelease
)

Variables

This section is empty.

Functions

func GetEnvironment

func GetEnvironment() string

GetEnvironment returns the environment name. It's taken from "environment" key of the global config.Config. The default value is "default".

func GetProfileString

func GetProfileString() string

GetProfileString returns the current Profile value, taken from GetProfile, in its string form.

func IsTerminal

func IsTerminal() bool

IsTerminal checks whether the app is being run inside an interactive terminal

func SetProfile

func SetProfile(profile Profile)

SetProfile sets the global value of Profile.

Types

type AppInfo

type AppInfo struct {
	// Name is the name of the application.
	Name string

	// Version is the version of the application.
	Version string

	// Environment is the name of the current environment, taken from GetEnvironment.
	Environment string

	// Profile is the string representation of current Profile, taken from GetProfileString.
	Profile string

	// Hostname is the hostname currently set in the system.
	Hostname string

	// StartupTime is the exact time when the application was started.
	StartupTime time.Time

	// BuildCommit is a Git revision from which the app was build.
	BuildCommit string

	// BuildCommit is the time in which Git revision used to build the app has been made.
	BuildTime string
}

AppInfo represents some basic information about the current app's runtime.

func Build

func Build(appName, appVersion string) AppInfo

Build builds AppInfo instance.

func (AppInfo) String

func (info AppInfo) String() string

String returns AppInfo in its string form.

type Profile

type Profile = int

Profile represents a global setting of the application, making changes to its default behaviors.

func GetProfile

func GetProfile() Profile

GetProfile returns the current Profile of the app. It's taken from "profile" key of the global config.Config. The default value is ProfileDebug. GetProfile caches the profile value when called for the first time.

Jump to

Keyboard shortcuts

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