fix golint issues, exported doc (#451)
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
//go:generate mockgen -package internal -destination statewatcher_mock.go -source statewatcher.go etcdConn
|
||||
|
||||
package internal
|
||||
|
||||
import (
|
||||
|
||||
@@ -2,14 +2,17 @@ package errorx
|
||||
|
||||
import "sync/atomic"
|
||||
|
||||
// AtomicError defines an atomic error.
|
||||
type AtomicError struct {
|
||||
err atomic.Value // error
|
||||
}
|
||||
|
||||
// Set sets the error.
|
||||
func (ae *AtomicError) Set(err error) {
|
||||
ae.err.Store(err)
|
||||
}
|
||||
|
||||
// Load returns the error.
|
||||
func (ae *AtomicError) Load() error {
|
||||
if v := ae.err.Load(); v != nil {
|
||||
return v.(error)
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package naming
|
||||
|
||||
// Namer interface wraps the method Name.
|
||||
type Namer interface {
|
||||
Name() string
|
||||
}
|
||||
|
||||
@@ -8,11 +8,12 @@ import (
|
||||
"github.com/tal-tech/go-zero/core/rescue"
|
||||
)
|
||||
|
||||
// GoSafe runs the given fn using another goroutine, recovers if fn panics.
|
||||
func GoSafe(fn func()) {
|
||||
go RunSafe(fn)
|
||||
}
|
||||
|
||||
// Only for debug, never use it in production
|
||||
// RoutineId is only for debug, never use it in production.
|
||||
func RoutineId() uint64 {
|
||||
b := make([]byte, 64)
|
||||
b = b[:runtime.Stack(b, false)]
|
||||
@@ -24,6 +25,7 @@ func RoutineId() uint64 {
|
||||
return n
|
||||
}
|
||||
|
||||
// RunSafe runs the given fn, recovers if fn panics.
|
||||
func RunSafe(fn func()) {
|
||||
defer rescue.Recover()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user