mode

package module
v1.0.7 Latest Latest
Warning

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

Go to latest
Published: Jan 29, 2025 License: BSD-3-Clause Imports: 3 Imported by: 1

README

gouef/mode

Mode of project

GoDoc GitHub stars Go Report Card codecov

Vesions

Stable Version GitHub Release GitHub Release

Introduction

Mode of project, like Release, Debug, Testing

Examples

Basic
package main
import "github.com/gouef/mode"

func main()  {
    m, err := mode.NewBasicMode()
	
	if err != nil {
		// do something
    }
    
    // some code
    if r, _ := m.IsRelease(); r {
        // some code
    }
}
Additional modes
package main
import "github.com/gouef/mode"

func main()  {
	modes := []string{"staging"}
	m, err := mode.NewMode(modes)

	if err != nil {
		// do something
	}

	// some code
	if r, _ := m.IsRelease(); r {
		m.EnableMode("staging")
	}
	
	if sm, _ := m.IsMode("staging"); sm {
		// some code
	}
}

Documentation

Index

Constants

View Source
const (
	// DebugMode mode is debug.
	DebugMode = "debug"
	// ReleaseMode mode is release.
	ReleaseMode = "release"
	// TestMode mode is test.
	TestMode = "test"
)
View Source
const EnvMode = "ENV_MODE"

Variables

This section is empty.

Functions

This section is empty.

Types

type Mode

type Mode struct {
	// contains filtered or unexported fields
}

func NewBasicMode

func NewBasicMode() (*Mode, error)

NewBasicMode create basic Mode with debug, release, test Example:

mode, err := mode.NewBaseMode()

func NewMode

func NewMode(additionalModes []string) (*Mode, error)

NewMode create Mode Example:

modes := []string{"staging"}
mode, err := mode.NewMode(modes)

func (*Mode) AddMode

func (m *Mode) AddMode(mode string) *Mode

AddMode add next available mode

func (*Mode) EnableDebug

func (m *Mode) EnableDebug() (bool, error)

EnableDebug enable debug mode

func (*Mode) EnableMode

func (m *Mode) EnableMode(mode string) (bool, error)

EnableMode enable specific mode

func (*Mode) EnableRelease

func (m *Mode) EnableRelease() (bool, error)

EnableRelease enable release mode

func (*Mode) EnableTest

func (m *Mode) EnableTest() (bool, error)

EnableTest enable test mode

func (*Mode) GetMode

func (m *Mode) GetMode() string

GetMode return current set mode

func (*Mode) IsDebug

func (m *Mode) IsDebug() (bool, error)

IsDebug check if mode is debug

func (*Mode) IsMode

func (m *Mode) IsMode(mode string) (bool, error)

IsMode check if mode is your specific

func (*Mode) IsRelease

func (m *Mode) IsRelease() (bool, error)

IsRelease check if mode is release

func (*Mode) IsTest

func (m *Mode) IsTest() (bool, error)

IsTest check if mode is test

func (Mode) Modes added in v1.0.3

func (m Mode) Modes() []string

Modes return available modes

Jump to

Keyboard shortcuts

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