mirror of https://github.com/gofiber/fiber.git
fix: better configuration
parent
e29633807c
commit
efeffa84f8
|
@ -253,7 +253,6 @@ issues:
|
|||
exclude-case-sensitive: true
|
||||
max-issues-per-linter: 0
|
||||
max-same-issues: 0
|
||||
uniq-by-line: false
|
||||
exclude-dirs:
|
||||
- internal # TODO: Do not ignore internal packages
|
||||
exclude-files:
|
||||
|
@ -271,7 +270,10 @@ issues:
|
|||
linters:
|
||||
- bodyclose
|
||||
- err113
|
||||
# fix: true
|
||||
- source: 'fmt.Fprintf?'
|
||||
linters:
|
||||
- errcheck
|
||||
- revive
|
||||
|
||||
linters:
|
||||
enable:
|
||||
|
|
|
@ -4585,7 +4585,7 @@ func Test_Ctx_SendStreamWriter(t *testing.T) {
|
|||
|
||||
err = c.SendStreamWriter(func(w *bufio.Writer) {
|
||||
for lineNum := 1; lineNum <= 5; lineNum++ {
|
||||
fmt.Fprintf(w, "Line %d\n", lineNum) //nolint:errcheck,revive // It is fine to ignore the error
|
||||
fmt.Fprintf(w, "Line %d\n", lineNum)
|
||||
if err := w.Flush(); err != nil {
|
||||
t.Errorf("unexpected error: %s", err)
|
||||
return
|
||||
|
@ -4607,7 +4607,7 @@ func Test_Ctx_SendStreamWriter_Interrupted(t *testing.T) {
|
|||
app.Get("/", func(c Ctx) error {
|
||||
return c.SendStreamWriter(func(w *bufio.Writer) {
|
||||
for lineNum := 1; lineNum <= 5; lineNum++ {
|
||||
fmt.Fprintf(w, "Line %d\n", lineNum) //nolint:errcheck // It is fine to ignore the error
|
||||
fmt.Fprintf(w, "Line %d\n", lineNum)
|
||||
|
||||
if err := w.Flush(); err != nil {
|
||||
if lineNum < 3 {
|
||||
|
@ -4951,11 +4951,11 @@ func Test_Ctx_BodyStreamWriter(t *testing.T) {
|
|||
ctx := &fasthttp.RequestCtx{}
|
||||
|
||||
ctx.SetBodyStreamWriter(func(w *bufio.Writer) {
|
||||
fmt.Fprintf(w, "body writer line 1\n") //nolint:errcheck // It is fine to ignore the error
|
||||
fmt.Fprintf(w, "body writer line 1\n")
|
||||
if err := w.Flush(); err != nil {
|
||||
t.Errorf("unexpected error: %s", err)
|
||||
}
|
||||
fmt.Fprintf(w, "body writer line 2\n") //nolint:errcheck // It is fine to ignore the error
|
||||
fmt.Fprintf(w, "body writer line 2\n")
|
||||
})
|
||||
|
||||
require.True(t, ctx.IsBodyStream())
|
||||
|
|
32
listen.go
32
listen.go
|
@ -366,38 +366,35 @@ func (app *App) startupMessage(addr string, isTLS bool, pids string, cfg ListenC
|
|||
out = colorable.NewNonColorable(os.Stdout)
|
||||
}
|
||||
|
||||
fmt.Fprintf(out, "%s\n", fmt.Sprintf(figletFiberText, colors.Red+"v"+Version+colors.Reset)) //nolint:errcheck,revive // ignore error
|
||||
fmt.Fprintf(out, strings.Repeat("-", 50)+"\n") //nolint:errcheck,revive // ignore error
|
||||
fmt.Fprintf(out, "%s\n", fmt.Sprintf(figletFiberText, colors.Red+"v"+Version+colors.Reset))
|
||||
fmt.Fprintf(out, strings.Repeat("-", 50)+"\n")
|
||||
|
||||
if host == "0.0.0.0" {
|
||||
//nolint:errcheck,revive // ignore error
|
||||
fmt.Fprintf(out,
|
||||
"%sINFO%s Server started on: \t%s%s://127.0.0.1:%s%s (bound on host 0.0.0.0 and port %s)\n",
|
||||
colors.Green, colors.Reset, colors.Blue, scheme, port, colors.Reset, port)
|
||||
} else {
|
||||
//nolint:errcheck,revive // ignore error
|
||||
fmt.Fprintf(out,
|
||||
"%sINFO%s Server started on: \t%s%s%s\n",
|
||||
colors.Green, colors.Reset, colors.Blue, fmt.Sprintf("%s://%s:%s", scheme, host, port), colors.Reset)
|
||||
}
|
||||
|
||||
if app.config.AppName != "" {
|
||||
fmt.Fprintf(out, "%sINFO%s Application name: \t\t%s%s%s\n", colors.Green, colors.Reset, colors.Blue, app.config.AppName, colors.Reset) //nolint:errcheck,revive // ignore error
|
||||
fmt.Fprintf(out, "%sINFO%s Application name: \t\t%s%s%s\n", colors.Green, colors.Reset, colors.Blue, app.config.AppName, colors.Reset)
|
||||
}
|
||||
|
||||
//nolint:errcheck,revive // ignore error
|
||||
fmt.Fprintf(out,
|
||||
"%sINFO%s Total handlers count: \t%s%s%s\n",
|
||||
colors.Green, colors.Reset, colors.Blue, strconv.Itoa(int(app.handlersCount)), colors.Reset)
|
||||
|
||||
if isPrefork == "Enabled" {
|
||||
fmt.Fprintf(out, "%sINFO%s Prefork: \t\t\t%s%s%s\n", colors.Green, colors.Reset, colors.Blue, isPrefork, colors.Reset) //nolint:errcheck,revive // ignore error
|
||||
fmt.Fprintf(out, "%sINFO%s Prefork: \t\t\t%s%s%s\n", colors.Green, colors.Reset, colors.Blue, isPrefork, colors.Reset)
|
||||
} else {
|
||||
fmt.Fprintf(out, "%sINFO%s Prefork: \t\t\t%s%s%s\n", colors.Green, colors.Reset, colors.Red, isPrefork, colors.Reset) //nolint:errcheck,revive // ignore error
|
||||
fmt.Fprintf(out, "%sINFO%s Prefork: \t\t\t%s%s%s\n", colors.Green, colors.Reset, colors.Red, isPrefork, colors.Reset)
|
||||
}
|
||||
|
||||
fmt.Fprintf(out, "%sINFO%s PID: \t\t\t%s%v%s\n", colors.Green, colors.Reset, colors.Blue, os.Getpid(), colors.Reset) //nolint:errcheck,revive // ignore error
|
||||
fmt.Fprintf(out, "%sINFO%s Total process count: \t%s%s%s\n", colors.Green, colors.Reset, colors.Blue, procs, colors.Reset) //nolint:errcheck,revive // ignore error
|
||||
fmt.Fprintf(out, "%sINFO%s PID: \t\t\t%s%v%s\n", colors.Green, colors.Reset, colors.Blue, os.Getpid(), colors.Reset)
|
||||
fmt.Fprintf(out, "%sINFO%s Total process count: \t%s%s%s\n", colors.Green, colors.Reset, colors.Blue, procs, colors.Reset)
|
||||
|
||||
if cfg.EnablePrefork {
|
||||
// Turn the `pids` variable (in the form ",a,b,c,d,e,f,etc") into a slice of PIDs
|
||||
|
@ -408,7 +405,7 @@ func (app *App) startupMessage(addr string, isTLS bool, pids string, cfg ListenC
|
|||
}
|
||||
}
|
||||
|
||||
fmt.Fprintf(out, "%sINFO%s Child PIDs: \t\t%s", colors.Green, colors.Reset, colors.Blue) //nolint:errcheck,revive // ignore error
|
||||
fmt.Fprintf(out, "%sINFO%s Child PIDs: \t\t%s", colors.Green, colors.Reset, colors.Blue)
|
||||
totalPids := len(pidSlice)
|
||||
rowTotalPidCount := 10
|
||||
|
||||
|
@ -421,17 +418,17 @@ func (app *App) startupMessage(addr string, isTLS bool, pids string, cfg ListenC
|
|||
}
|
||||
|
||||
for n, pid := range pidSlice[start:end] {
|
||||
fmt.Fprintf(out, "%s", pid) //nolint:errcheck,revive // ignore error
|
||||
fmt.Fprintf(out, "%s", pid)
|
||||
if n+1 != len(pidSlice[start:end]) {
|
||||
fmt.Fprintf(out, ", ") //nolint:errcheck,revive // ignore error
|
||||
fmt.Fprintf(out, ", ")
|
||||
}
|
||||
}
|
||||
fmt.Fprintf(out, "\n%s", colors.Reset) //nolint:errcheck,revive // ignore error
|
||||
fmt.Fprintf(out, "\n%s", colors.Reset)
|
||||
}
|
||||
}
|
||||
|
||||
// add new Line as spacer
|
||||
fmt.Fprintf(out, "\n%s", colors.Reset) //nolint:errcheck,revive // ignore error
|
||||
fmt.Fprintf(out, "\n%s", colors.Reset)
|
||||
}
|
||||
|
||||
// printRoutesMessage print all routes with method, path, name and handlers
|
||||
|
@ -473,11 +470,10 @@ func (app *App) printRoutesMessage() {
|
|||
return routes[i].path < routes[j].path
|
||||
})
|
||||
|
||||
fmt.Fprintf(w, "%smethod\t%s| %spath\t%s| %sname\t%s| %shandlers\t%s\n", colors.Blue, colors.White, colors.Green, colors.White, colors.Cyan, colors.White, colors.Yellow, colors.Reset) //nolint:errcheck,revive // ignore error
|
||||
fmt.Fprintf(w, "%s------\t%s| %s----\t%s| %s----\t%s| %s--------\t%s\n", colors.Blue, colors.White, colors.Green, colors.White, colors.Cyan, colors.White, colors.Yellow, colors.Reset) //nolint:errcheck,revive // ignore error
|
||||
fmt.Fprintf(w, "%smethod\t%s| %spath\t%s| %sname\t%s| %shandlers\t%s\n", colors.Blue, colors.White, colors.Green, colors.White, colors.Cyan, colors.White, colors.Yellow, colors.Reset)
|
||||
fmt.Fprintf(w, "%s------\t%s| %s----\t%s| %s----\t%s| %s--------\t%s\n", colors.Blue, colors.White, colors.Green, colors.White, colors.Cyan, colors.White, colors.Yellow, colors.Reset)
|
||||
|
||||
for _, route := range routes {
|
||||
//nolint:errcheck,revive // ignore error
|
||||
fmt.Fprintf(w, "%s%s\t%s| %s%s\t%s| %s%s\t%s| %s%s%s\n", colors.Blue, route.method, colors.White, colors.Green, route.path, colors.White, colors.Cyan, route.name, colors.White, colors.Yellow, route.handlers, colors.Reset)
|
||||
}
|
||||
|
||||
|
|
|
@ -53,9 +53,9 @@ func (l *defaultLogger) privateLogf(lv Level, format string, fmtArgs []any) {
|
|||
buf.WriteString(level)
|
||||
|
||||
if len(fmtArgs) > 0 {
|
||||
_, _ = fmt.Fprintf(buf, format, fmtArgs...) //nolint:errcheck // It is fine to ignore the error
|
||||
_, _ = fmt.Fprintf(buf, format, fmtArgs...)
|
||||
} else {
|
||||
_, _ = fmt.Fprint(buf, fmtArgs...) //nolint:errcheck // It is fine to ignore the error
|
||||
_, _ = fmt.Fprint(buf, fmtArgs...)
|
||||
}
|
||||
|
||||
_ = l.stdlog.Output(l.depth, buf.String()) //nolint:errcheck // It is fine to ignore the error
|
||||
|
|
|
@ -68,7 +68,7 @@ func Test_HTTPHandler(t *testing.T) {
|
|||
w.Header().Set("Header1", "value1")
|
||||
w.Header().Set("Header2", "value2")
|
||||
w.WriteHeader(http.StatusBadRequest)
|
||||
fmt.Fprintf(w, "request body is %q", body) //nolint:errcheck // not needed
|
||||
fmt.Fprintf(w, "request body is %q", body)
|
||||
}
|
||||
fiberH := HTTPHandlerFunc(http.HandlerFunc(nethttpH))
|
||||
fiberH = setFiberContextValueMiddleware(fiberH, expectedContextKey, expectedContextValue)
|
||||
|
|
|
@ -166,7 +166,7 @@ func writeLog(w io.Writer, msg []byte) {
|
|||
// Write error to output
|
||||
if _, err := w.Write([]byte(err.Error())); err != nil {
|
||||
// There is something wrong with the given io.Writer
|
||||
_, _ = fmt.Fprintf(os.Stderr, "Failed to write to log, %v\n", err) //nolint:errcheck // It is fine to ignore the error
|
||||
_, _ = fmt.Fprintf(os.Stderr, "Failed to write to log, %v\n", err)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -865,7 +865,7 @@ func Test_Logger_ByteSent_Streaming(t *testing.T) {
|
|||
for {
|
||||
i++
|
||||
msg := fmt.Sprintf("%d - the time is %v", i, time.Now())
|
||||
fmt.Fprintf(w, "data: Message: %s\n\n", msg) //nolint:errcheck // ignore error
|
||||
fmt.Fprintf(w, "data: Message: %s\n\n", msg)
|
||||
err := w.Flush()
|
||||
if err != nil {
|
||||
break
|
||||
|
@ -1049,7 +1049,7 @@ func Benchmark_Logger(b *testing.B) {
|
|||
for {
|
||||
i++
|
||||
msg := fmt.Sprintf("%d - the time is %v", i, time.Now())
|
||||
fmt.Fprintf(w, "data: Message: %s\n\n", msg) //nolint:errcheck // ignore error
|
||||
fmt.Fprintf(w, "data: Message: %s\n\n", msg)
|
||||
err := w.Flush()
|
||||
if err != nil {
|
||||
break
|
||||
|
@ -1217,7 +1217,7 @@ func Benchmark_Logger_Parallel(b *testing.B) {
|
|||
for {
|
||||
i++
|
||||
msg := fmt.Sprintf("%d - the time is %v", i, time.Now())
|
||||
fmt.Fprintf(w, "data: Message: %s\n\n", msg) //nolint:errcheck // ignore error
|
||||
fmt.Fprintf(w, "data: Message: %s\n\n", msg)
|
||||
err := w.Flush()
|
||||
if err != nil {
|
||||
break
|
||||
|
|
Loading…
Reference in New Issue