aboutsummaryrefslogtreecommitdiff
path: root/trunks.go
diff options
context:
space:
mode:
authorShulhan <ms@kilabit.info>2023-11-11 13:33:11 +0700
committerShulhan <ms@kilabit.info>2023-11-11 13:34:43 +0700
commit08852664aa6952e727addb0c24ad8f56274e09bb (patch)
treed4f59e9000a2676bf1c5952c0cbeb6a5ff1f7443 /trunks.go
parente56ee3e03a34fa738b626a4fd22fbc051bf7f0b0 (diff)
downloadgorankusu-08852664aa6952e727addb0c24ad8f56274e09bb.tar.xz
Makefile: replace the Go linter and apply all their recommendations
Previously, we use golangci-lint as linter. This linter does not provides any useful recommendation lately and the development is quite a mess, sometimes its break when using Go tip. In this changes we replace it with revive, fieldalignment, and shadow; and fix all of their recommendations.
Diffstat (limited to 'trunks.go')
-rw-r--r--trunks.go29
1 files changed, 18 insertions, 11 deletions
diff --git a/trunks.go b/trunks.go
index 3043fc7..30d358a 100644
--- a/trunks.go
+++ b/trunks.go
@@ -17,9 +17,11 @@ import (
"github.com/shuLhan/share/lib/mlog"
)
-const (
- Version = `0.4.0`
+// Version of trunks module.
+const Version = `0.4.0`
+// List of default values.
+const (
DefaultAttackDuration = 10 * time.Second
DefaultAttackRatePerSecond = 500
DefaultAttackTimeout = 30 * time.Second
@@ -27,15 +29,19 @@ const (
DefaultMaxAttackRate = 3000
DefaultListenAddress = `127.0.0.1:8217`
+)
- // Setting this environment variable will enable trunks development
- // mode.
- EnvDevelopment = "TRUNKS_DEV"
+// EnvDevelopment setting this environment variable will enable trunks
+// development mode.
+const EnvDevelopment = "TRUNKS_DEV"
- // List of HTTP parameters.
+// List of HTTP parameters.
+const (
paramNameName = "name"
+)
- // List of HTTP APIs.
+// List of HTTP APIs.
+const (
pathApiAttackHttp = `/_trunks/api/attack/http`
pathApiAttackResult = `/_trunks/api/attack/result`
)
@@ -157,6 +163,7 @@ func (trunks *Trunks) RegisterNavLink(nav *NavLink) (err error) {
return nil
}
+// RegisterTarget register Target to be attached to Trunks.
func (trunks *Trunks) RegisterTarget(target *Target) (err error) {
if target == nil {
return
@@ -191,7 +198,7 @@ func (trunks *Trunks) RunHttp(req *RunRequest) (res *RunResponse, err error) {
req.HttpTarget.ConvertParams = origHttpTarget.ConvertParams
res, err = trunks.runHttpTarget(req)
} else {
- req := generateRunRequest(trunks.Env, req, origTarget, origHttpTarget)
+ req = generateRunRequest(trunks.Env, req, origTarget, origHttpTarget)
res, err = req.HttpTarget.Run(req)
}
if err != nil {
@@ -212,9 +219,9 @@ func (trunks *Trunks) Start() (err error) {
mlog.Outf(`trunks: starting HTTP server at http://%s`, trunks.Env.ListenAddress)
go func() {
- err := trunks.Httpd.Start()
- if err != nil {
- trunks.errq <- err
+ var errStart = trunks.Httpd.Start()
+ if errStart != nil {
+ trunks.errq <- errStart
}
}()