plugcore

package
v0.0.0-...-6b6483a Latest Latest
Warning

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

Go to latest
Published: Aug 2, 2024 License: BSD-3-Clause Imports: 4 Imported by: 0

Documentation

Overview

Package plugcore is designed to be imported only from the plug package. All packages except plug or its artifacts must not import this package directly.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Get

func Get[T any](scope *Scope, s *Symbol[T], dflt T, recv any, params Params) T

Get returns an object that is bound to s, or dflt if s is bound nothing.

Types

type FuncRecorder

type FuncRecorder[T any] struct {
	// contains filtered or unexported fields
}

FuncRecorder records its function callings for later inspection in tests.

func (*FuncRecorder[T]) At

func (r *FuncRecorder[T]) At(i int) T

func (*FuncRecorder[T]) Count

func (r *FuncRecorder[T]) Count() int

func (*FuncRecorder[T]) Record

func (r *FuncRecorder[T]) Record(params Params)

type Object

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

func Set

func Set[T any](scope *Scope, s *Symbol[T], v T, recv any, params Params) *Object

Set binds s to v. If s does already bound to another object, it will unbound.

func (*Object) SetRecorder

func (obj *Object) SetRecorder(r Recorder)

type Params

type Params = map[string]any

type Recorder

type Recorder interface {
	Record(params Params)
}

Recorder is the interface that wraps the Record method.

type Scope

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

func NewScope

func NewScope(skip int) *Scope

func NewScopeFrom

func NewScopeFrom(parent *Scope, skip int) *Scope

func (*Scope) Delete

func (s *Scope) Delete()

Delete deletes all objects that were bound by Set from s then deletes s itself from the internal state.

type Symbol

type Symbol[T any] struct {
	// contains filtered or unexported fields
}

Symbol represents an object that will be replaced.

func Func

func Func[F any](name string, f F) *Symbol[F]

Func returns a symbol constructed with both the name and the function is referenced to. The name syntax must be either $package.$function or $package.$type.$method.

For example:

  • math/rand/v2.N
  • net/http.Client.Do

func (*Symbol[T]) String

func (s *Symbol[T]) String() string

Jump to

Keyboard shortcuts

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