Skip to content
This repository was archived by the owner on Sep 6, 2020. It is now read-only.

Commit befbd3e

Browse files
committed
Simplify context error and egos
1 parent 15caf42 commit befbd3e

File tree

2 files changed

+8
-8
lines changed

2 files changed

+8
-8
lines changed

context.go

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -165,11 +165,9 @@ func (c *Context) Error(err error) *util.Error {
165165
if err == nil {
166166
panic("err is nil")
167167
}
168-
var parsedError *util.Error
169-
switch err.(type) {
170-
case *util.Error:
171-
parsedError = err.(*util.Error)
172-
default:
168+
169+
parsedError, ok := err.(*util.Error)
170+
if !ok {
173171
parsedError = &util.Error{
174172
Err: err,
175173
Type: util.ErrorTypePrivate,

egoS/egos.go

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,10 @@ import (
1212
"github.com/go-ego/ego"
1313
)
1414

15-
var once sync.Once
16-
var internalEngine *ego.Engine
15+
var (
16+
once sync.Once
17+
internalEngine *ego.Engine
18+
)
1719

1820
func engine() *ego.Engine {
1921
once.Do(func() {
@@ -128,7 +130,7 @@ func Run(addr ...string) (err error) {
128130
// RunTLS : The router is attached to a http.Server and starts listening and serving HTTPS requests.
129131
// It is a shortcut for http.ListenAndServeTLS(addr, certFile, keyFile, router)
130132
// Note: this method will block the calling goroutine undefinitelly unless an error happens.
131-
func RunTLS(addr string, certFile string, keyFile string) (err error) {
133+
func RunTLS(addr, certFile, keyFile string) (err error) {
132134
return engine().RunTLS(addr, certFile, keyFile)
133135
}
134136

0 commit comments

Comments
 (0)