lang

package
v0.1.9 Latest Latest
Warning

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

Go to latest
Published: Apr 23, 2023 License: MIT Imports: 6 Imported by: 49

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Close

func Close(t io.Closer) error

func Dispose

func Dispose(t Disposable) error

func Release

func Release(pool ReleasePool) error

func StringifyObject added in v0.1.2

func StringifyObject(o interface{}) string

StringifyObject 生成对象的摘要字符串, 类似于 java.lang.Object.toString()

Types

type BaseObject added in v0.0.47

type BaseObject interface {
	Stringer
	Equals(other BaseObject) bool
	HashCode() int
}

BaseObject 基本对象:比Object更复杂一点点

type DefaultErrorCollector

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

func (*DefaultErrorCollector) Append

func (inst *DefaultErrorCollector) Append(err error)

func (*DefaultErrorCollector) AppendIfFalse

func (inst *DefaultErrorCollector) AppendIfFalse(value bool, msg string)

func (*DefaultErrorCollector) AppendIfNil

func (inst *DefaultErrorCollector) AppendIfNil(value Object, msg string)

func (*DefaultErrorCollector) LastError

func (inst *DefaultErrorCollector) LastError() error

func (*DefaultErrorCollector) Result

func (inst *DefaultErrorCollector) Result() error

type Disposable

type Disposable interface {
	Dispose() error
}

Disposable 接口用于释放对象持有的资源

func DisposableForFunc added in v0.0.41

func DisposableForFunc(fn DisposableFunc) Disposable

DisposableForFunc 函数创建一个 DisposableFunc 的包装

type DisposableFunc added in v0.0.41

type DisposableFunc func() error

DisposableFunc Disposable 接口的函数形式

type ErrorCollector

type ErrorCollector interface {
	Append(err error)
	AppendIfFalse(ok bool, msg string)
	AppendIfNil(target Object, msg string)

	LastError() error
	Result() error
}

ErrorCollector 表示一个错误收集器

func NewErrorCollector

func NewErrorCollector() ErrorCollector

NewErrorCollector 创建一个错误收集器

type ErrorHandler

type ErrorHandler interface {
	HandleError(err error) error
}

ErrorHandler 表示一个错误处理器

func DefaultErrorHandler

func DefaultErrorHandler() ErrorHandler

DefaultErrorHandler 创建一个默认的错误处理器

func NewErrorHandlerForFunc added in v0.0.48

func NewErrorHandlerForFunc(fn ErrorHandlerFunc) ErrorHandler

NewErrorHandlerForFunc 创建一个新的 ErrorHandler 作为fn的代理

type ErrorHandlerFunc added in v0.0.48

type ErrorHandlerFunc func(err error) error

ErrorHandlerFunc 是ErrorHandler的函数形式

type Object

type Object interface {
}

Object 对象:相当于 interface{}

type PriorityProvider

type PriorityProvider interface {
	Priority() int
}

type ReleasePool

type ReleasePool interface {
	Release() error
	Push(target Disposable)
}

func CreateReleasePool

func CreateReleasePool() ReleasePool

type Serializable added in v0.0.47

type Serializable interface {
	Stringer
}

Serializable 一个标记接口:表示对象可以序列化

type SimpleReleasePool

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

func (*SimpleReleasePool) Push

func (inst *SimpleReleasePool) Push(target Disposable)

func (*SimpleReleasePool) Release

func (inst *SimpleReleasePool) Release() error

type Stringer added in v0.0.33

type Stringer interface {
	String() string
}

Stringer 是一个简单的接口,它把对象格式化为字符串

type TryChain

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

func (*TryChain) Result

func (inst *TryChain) Result() error

func (*TryChain) Try

func (inst *TryChain) Try(task func() error) *TryChain

type URI added in v0.0.39

type URI interface {
	URL() *url.URL
	String() string

	Scheme() string
	User() string // username and password information
	Host() string // host or host:port
	Port() int
	Path() string     // path (relative paths may omit leading slash)
	Query() string    // encoded query values, without '?'
	Fragment() string // fragment for references, without '#'
}

URI 提供一个只读的URI接口

func CreateURI added in v0.0.39

func CreateURI(url *url.URL) URI

CreateURI 创建URI

func ParseURI added in v0.0.39

func ParseURI(str string) (URI, error)

ParseURI 解析URI

Jump to

Keyboard shortcuts

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