Documentation ¶
Overview ¶
Package common contains common utilities that are shared among other packages. See each sub-package for detail.
Index ¶
- Variables
- func Close(obj interface{}) error
- func CreateObject(ctx context.Context, config interface{}) (interface{}, error)
- func Error2(v interface{}, err error) error
- func Must(err error)
- func Must2(v interface{}, err error) interface{}
- func RegisterConfig(config interface{}, configCreator ConfigCreator) error
- type ChainedClosable
- type Closable
- type ConfigCreator
- type HasType
- type Runnable
Constants ¶
This section is empty.
Variables ¶
View Source
var ( // ErrNoClue is for the situation that existing information is not enough to make a decision. For example, Router may return this error when there is no suitable route. ErrNoClue = errors.New("not enough information for making a decision") )
Functions ¶
func Close ¶ added in v3.8.1
func Close(obj interface{}) error
Close closes the obj if it is a Closable.
func CreateObject ¶
CreateObject creates an object by its config. The config type must be registered through RegisterConfig().
func Must2 ¶
func Must2(v interface{}, err error) interface{}
Must2 panics if the second parameter is not nil, otherwise returns the first parameter.
func RegisterConfig ¶
func RegisterConfig(config interface{}, configCreator ConfigCreator) error
RegisterConfig registers a global config creator. The config can be nil but must have a type.
Types ¶
type ChainedClosable ¶ added in v3.11.1
type ChainedClosable []Closable
func NewChainedClosable ¶ added in v3.11.1
func NewChainedClosable(c ...Closable) ChainedClosable
func (ChainedClosable) Close ¶ added in v3.11.1
func (cc ChainedClosable) Close() error
type Closable ¶ added in v3.8.1
type Closable interface { // Close release all resources used by this object, including goroutines. Close() error }
Closable is the interface for objects that can release its resources.
type ConfigCreator ¶
ConfigCreator is a function to create an object by a config.
Directories ¶
Path | Synopsis |
---|---|
Package buf provides a light-weight memory allocation mechanism.
|
Package buf provides a light-weight memory allocation mechanism. |
Package crypto provides common crypto libraries for V2Ray.
|
Package crypto provides common crypto libraries for V2Ray. |
Package dice contains common functions to generate random number.
|
Package dice contains common functions to generate random number. |
Package errors is a drop-in replacement for Golang lib 'errors'.
|
Package errors is a drop-in replacement for Golang lib 'errors'. |
Package net is a drop-in replacement to Golang's net package, with some more functionalities.
|
Package net is a drop-in replacement to Golang's net package, with some more functionalities. |
Package session provides functions for sessions of incoming requests.
|
Package session provides functions for sessions of incoming requests. |
Click to show internal directories.
Click to hide internal directories.