shared

package module
v0.1.6 Latest Latest
Warning

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

Go to latest
Published: Nov 14, 2025 License: MIT Imports: 6 Imported by: 9

README ¶

Shared Vars

Build Status Coverage Status GoDevDoc Time Tracker Code lines Comments

Shared provides space and contract to share variables between test helpers and libraries.

Documentation ¶

Overview ¶

Package shared provides space to share variables.

Index ¶

Constants ¶

This section is empty.

Variables ¶

This section is empty.

Functions ¶

func DecodeJSONNumber ¶ added in v0.1.6

func DecodeJSONNumber(n json.Number) interface{}

DecodeJSONNumber tries to decode a json.Number into the most appropriate type (unit64, int64, float64). If nothing works, json.Number is returned as is.

func VarToContext ¶ added in v0.1.5

func VarToContext(ctx context.Context, key string, value interface{}) context.Context

VarToContext adds variable to context.

func VarsFromContext ¶ added in v0.1.5

func VarsFromContext(ctx context.Context) map[string]interface{}

VarsFromContext returns variables from context.

Types ¶

type Vars ¶

type Vars struct {
	// VarPrefix determines which cell values should be collected as vars and replaced with values in usages.
	// Default is '$', e.g. $id1 would be treated as variable.
	VarPrefix string
	// contains filtered or unexported fields
}

Vars keeps values of named variables.

func (*Vars) Fork ¶ added in v0.1.4

func (v *Vars) Fork(ctx context.Context) (context.Context, *Vars)

Fork instruments context with a copy of Vars or returns Vars that are already in context.

func (*Vars) Get ¶

func (v *Vars) Get(s string) (interface{}, bool)

Get returns variable value if is exists.

func (*Vars) GetAll ¶

func (v *Vars) GetAll() map[string]interface{}

GetAll returns all variables with values.

func (*Vars) IsVar ¶

func (v *Vars) IsVar(s string) bool

IsVar checks if string looks like a variable name.

func (*Vars) OnSet ¶ added in v0.1.1

func (v *Vars) OnSet(f func(key string, val interface{}))

OnSet adds callback to invoke when variable is set.

All callbacks are removed on Reset.

func (*Vars) Reset ¶

func (v *Vars) Reset()

Reset removes all variables.

func (*Vars) Set ¶

func (v *Vars) Set(key string, val interface{})

Set sets variable by name.

Jump to

Keyboard shortcuts

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