Passed
Pull Request — main (#166)
by Yume
02:10
created

app/v2/app.go   A

Size/Duplication

Total Lines 27
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
cc 3
eloc 14
dl 0
loc 27
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A v2.GetEchoInstance 0 10 2
A v2.registerMiddlewares 0 1 1
1
package v2
2
3
import (
4
	"sync"
5
6
	"github.com/labstack/echo/v4"
7
)
8
9
var (
10
	instance *echo.Echo //nolint:gochecknoglobals //Singleton
11
	once     sync.Once  //nolint:gochecknoglobals //Singleton
12
)
13
14
// New returns a new Echo instance.
15
func GetEchoInstance() *echo.Echo {
16
	once.Do(func() {
17
		instance = echo.New()
18
		registerMiddlewares(instance)
19
20
		registerStaticRoutes(instance)
21
22
		registerRoutes(instance)
23
	})
24
	return instance
25
}
26
27
func registerMiddlewares(_ *echo.Echo) {
28
}
29