import "github.com/v2ray/v2ray-core/common"
Package common contains common utilities that are shared among other packages. See each sub-package for detail.
common.go errors.generated.go interfaces.go type.go
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") )
Close closes the obj if it is a Closable.
v2ray:api:beta
CreateObject creates an object by its config. The config type must be registered through RegisterConfig().
Error2 returns the err from the 2nd parameter.
GetGOBIN returns GOBIN environment variable as a string. It will NOT be empty.
GetGOPATH returns GOPATH environment variable as a string. It will NOT be empty.
GetModuleName returns the value of module in `go.mod` file.
GetRuntimeEnv returns the value of runtime environment variable, that is set by running following command: `go env -w key=value`.
Interrupt calls Interrupt() if object implements Interruptible interface, or Close() if the object implements Closable interface.
v2ray:api:beta
Must panics if err is not nil.
Must2 panics if the second parameter is not nil, otherwise returns the first parameter.
func RegisterConfig(config interface{}, configCreator ConfigCreator) error
RegisterConfig registers a global config creator. The config can be nil but must have a type.
ChainedClosable is a Closable that consists of multiple Closable objects.
func (cc ChainedClosable) Close() error
Close implements Closable.
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.
v2ray:api:beta
ConfigCreator is a function to create an object by a config.
type HasType interface { // Type returns the type of the object. // Usually it returns (*Type)(nil) of the object. Type() interface{} }
HasType is the interface for objects that knows its type.
type Interruptible interface {
Interrupt()
}
Interruptible is an interface for objects that can be stopped before its completion.
v2ray:api:beta
type Runnable interface { // Start starts the runnable object. Upon the method returning nil, the object begins to function properly. Start() error Closable }
Runnable is the interface for objects that can start to work and stop on demand.
Path | Synopsis |
---|---|
antireplay | |
bitmask | |
bytespool | |
cmdarg | |
crypto/internal | |
errors/errorgen | |
mux | |
peer | |
platform/filesystem | |
protocol/http | |
serial | |
signal | |
signal/done | |
signal/pubsub | |
signal/semaphore | |
stack | |
strmatcher | |
task |
Package common imports 9 packages (graph) and is imported by 11 packages. Updated 2020-12-29. Refresh now. Tools for package owners.