mirror of
https://github.com/yusing/godoxy.git
synced 2025-06-09 04:52:35 +02:00
fixed / suppressed (irrelevant) golangci-lint errors
This commit is contained in:
parent
d82594bf09
commit
4d94d12e9c
22 changed files with 89 additions and 69 deletions
|
@ -1,5 +1,9 @@
|
||||||
# Stage 1: Builder
|
# Stage 1: Builder
|
||||||
FROM golang:1.23.3-alpine AS builder
|
FROM golang:1.23.3-alpine AS builder
|
||||||
|
HEALTHCHECK NONE
|
||||||
|
|
||||||
|
# package version does not matter
|
||||||
|
# trunk-ignore(hadolint/DL3018)
|
||||||
RUN apk add --no-cache tzdata make
|
RUN apk add --no-cache tzdata make
|
||||||
|
|
||||||
WORKDIR /src
|
WORKDIR /src
|
||||||
|
|
|
@ -160,7 +160,7 @@ func main() {
|
||||||
// grafully shutdown
|
// grafully shutdown
|
||||||
logging.Info().Msg("shutting down")
|
logging.Info().Msg("shutting down")
|
||||||
task.CancelGlobalContext()
|
task.CancelGlobalContext()
|
||||||
task.GlobalContextWait(time.Second * time.Duration(config.Value().TimeoutShutdown))
|
_ = task.GlobalContextWait(time.Second * time.Duration(config.Value().TimeoutShutdown))
|
||||||
}
|
}
|
||||||
|
|
||||||
func prepareDirectory(dir string) {
|
func prepareDirectory(dir string) {
|
||||||
|
|
|
@ -44,6 +44,8 @@ var (
|
||||||
watcherMap = F.NewMapOf[string, *Watcher]()
|
watcherMap = F.NewMapOf[string, *Watcher]()
|
||||||
watcherMapMu sync.Mutex
|
watcherMapMu sync.Mutex
|
||||||
|
|
||||||
|
errShouldNotReachHere = errors.New("should not reach here")
|
||||||
|
|
||||||
logger = logging.With().Str("module", "idle_watcher").Logger()
|
logger = logging.With().Str("module", "idle_watcher").Logger()
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -53,7 +55,7 @@ func registerWatcher(providerSubtask task.Task, entry route.Entry, waker *waker)
|
||||||
cfg := entry.IdlewatcherConfig()
|
cfg := entry.IdlewatcherConfig()
|
||||||
|
|
||||||
if cfg.IdleTimeout == 0 {
|
if cfg.IdleTimeout == 0 {
|
||||||
panic("should not reach here")
|
panic(errShouldNotReachHere)
|
||||||
}
|
}
|
||||||
|
|
||||||
watcherMapMu.Lock()
|
watcherMapMu.Lock()
|
||||||
|
@ -104,10 +106,12 @@ func (w *Watcher) Wake() error {
|
||||||
|
|
||||||
// WakeDebug logs a debug message related to waking the container.
|
// WakeDebug logs a debug message related to waking the container.
|
||||||
func (w *Watcher) WakeDebug() *zerolog.Event {
|
func (w *Watcher) WakeDebug() *zerolog.Event {
|
||||||
|
//nolint:zerologlint
|
||||||
return w.Debug().Str("action", "wake")
|
return w.Debug().Str("action", "wake")
|
||||||
}
|
}
|
||||||
|
|
||||||
func (w *Watcher) WakeTrace() *zerolog.Event {
|
func (w *Watcher) WakeTrace() *zerolog.Event {
|
||||||
|
//nolint:zerologlint
|
||||||
return w.Trace().Str("action", "wake")
|
return w.Trace().Str("action", "wake")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -177,7 +181,7 @@ func (w *Watcher) wakeIfStopped() error {
|
||||||
case "running":
|
case "running":
|
||||||
return nil
|
return nil
|
||||||
default:
|
default:
|
||||||
panic("should not reach here")
|
panic(errShouldNotReachHere)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -191,7 +195,7 @@ func (w *Watcher) getStopCallback() StopCallback {
|
||||||
case idlewatcher.StopMethodKill:
|
case idlewatcher.StopMethodKill:
|
||||||
cb = w.containerKill
|
cb = w.containerKill
|
||||||
default:
|
default:
|
||||||
panic("should not reach here")
|
panic(errShouldNotReachHere)
|
||||||
}
|
}
|
||||||
return func() error {
|
return func() error {
|
||||||
ctx, cancel := context.WithTimeout(w.task.Context(), time.Duration(w.StopTimeout)*time.Second)
|
ctx, cancel := context.WithTimeout(w.task.Context(), time.Duration(w.StopTimeout)*time.Second)
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
package error
|
package err
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"errors"
|
"errors"
|
||||||
|
@ -6,6 +6,8 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
// baseError is an immutable wrapper around an error.
|
// baseError is an immutable wrapper around an error.
|
||||||
|
//
|
||||||
|
//nolint:recvcheck
|
||||||
type baseError struct {
|
type baseError struct {
|
||||||
Err error `json:"err"`
|
Err error `json:"err"`
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
package error
|
package err
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
@ -60,7 +60,7 @@ func (b *Builder) Add(err error) *Builder {
|
||||||
b.Lock()
|
b.Lock()
|
||||||
defer b.Unlock()
|
defer b.Unlock()
|
||||||
|
|
||||||
switch err := err.(type) {
|
switch err := From(err).(type) {
|
||||||
case *baseError:
|
case *baseError:
|
||||||
b.errs = append(b.errs, err.Err)
|
b.errs = append(b.errs, err.Err)
|
||||||
case *nestedError:
|
case *nestedError:
|
||||||
|
@ -70,7 +70,7 @@ func (b *Builder) Add(err error) *Builder {
|
||||||
b.errs = append(b.errs, err)
|
b.errs = append(b.errs, err)
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
b.errs = append(b.errs, err)
|
panic("bug: should not reach here")
|
||||||
}
|
}
|
||||||
|
|
||||||
return b
|
return b
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
package error_test
|
package err_test
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
package error
|
package err
|
||||||
|
|
||||||
type Error interface {
|
type Error interface {
|
||||||
error
|
error
|
||||||
|
@ -24,6 +24,8 @@ type Error interface {
|
||||||
|
|
||||||
// this makes JSON marshaling work,
|
// this makes JSON marshaling work,
|
||||||
// as the builtin one doesn't.
|
// as the builtin one doesn't.
|
||||||
|
//
|
||||||
|
//nolint:errname
|
||||||
type errStr string
|
type errStr string
|
||||||
|
|
||||||
func (err errStr) Error() string {
|
func (err errStr) Error() string {
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
package error
|
package err
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"errors"
|
"errors"
|
||||||
|
@ -81,10 +81,10 @@ func TestErrorImmutability(t *testing.T) {
|
||||||
|
|
||||||
for range 3 {
|
for range 3 {
|
||||||
// t.Logf("%d: %v %T %s", i, errors.Unwrap(err), err, err)
|
// t.Logf("%d: %v %T %s", i, errors.Unwrap(err), err, err)
|
||||||
err.Subject("foo")
|
_ = err.Subject("foo")
|
||||||
ExpectFalse(t, strings.Contains(err.Error(), "foo"))
|
ExpectFalse(t, strings.Contains(err.Error(), "foo"))
|
||||||
|
|
||||||
err.With(err2)
|
_ = err.With(err2)
|
||||||
ExpectFalse(t, strings.Contains(err.Error(), "extra"))
|
ExpectFalse(t, strings.Contains(err.Error(), "extra"))
|
||||||
ExpectFalse(t, err.Is(err2))
|
ExpectFalse(t, err.Is(err2))
|
||||||
|
|
||||||
|
@ -102,7 +102,7 @@ func TestErrorWith(t *testing.T) {
|
||||||
ExpectTrue(t, err3.Is(err1))
|
ExpectTrue(t, err3.Is(err1))
|
||||||
ExpectTrue(t, err3.Is(err2))
|
ExpectTrue(t, err3.Is(err2))
|
||||||
|
|
||||||
err2.Subject("foo")
|
_ = err2.Subject("foo")
|
||||||
|
|
||||||
ExpectTrue(t, err3.Is(err1))
|
ExpectTrue(t, err3.Is(err1))
|
||||||
ExpectTrue(t, err3.Is(err2))
|
ExpectTrue(t, err3.Is(err2))
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
package error
|
package err
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/rs/zerolog"
|
"github.com/rs/zerolog"
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
package error
|
package err
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"errors"
|
"errors"
|
||||||
|
@ -6,6 +6,7 @@ import (
|
||||||
"strings"
|
"strings"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
//nolint:recvcheck
|
||||||
type nestedError struct {
|
type nestedError struct {
|
||||||
Err error `json:"err"`
|
Err error `json:"err"`
|
||||||
Extras []error `json:"extras"`
|
Extras []error `json:"extras"`
|
||||||
|
@ -66,7 +67,18 @@ func (err *nestedError) Is(other error) bool {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (err *nestedError) Error() string {
|
func (err *nestedError) Error() string {
|
||||||
return buildError(err, 0)
|
if err == nil {
|
||||||
|
return makeLine("<nil>", 0)
|
||||||
|
}
|
||||||
|
|
||||||
|
lines := make([]string, 0, 1+len(err.Extras))
|
||||||
|
if err.Err != nil {
|
||||||
|
lines = append(lines, makeLine(err.Err.Error(), 0))
|
||||||
|
}
|
||||||
|
if extras := makeLines(err.Extras, 1); len(extras) > 0 {
|
||||||
|
lines = append(lines, extras...)
|
||||||
|
}
|
||||||
|
return strings.Join(lines, "\n")
|
||||||
}
|
}
|
||||||
|
|
||||||
//go:inline
|
//go:inline
|
||||||
|
@ -86,7 +98,7 @@ func makeLines(errs []error, level int) []string {
|
||||||
}
|
}
|
||||||
lines := make([]string, 0, len(errs))
|
lines := make([]string, 0, len(errs))
|
||||||
for _, err := range errs {
|
for _, err := range errs {
|
||||||
switch err := err.(type) {
|
switch err := From(err).(type) {
|
||||||
case *nestedError:
|
case *nestedError:
|
||||||
if err.Err != nil {
|
if err.Err != nil {
|
||||||
lines = append(lines, makeLine(err.Err.Error(), level))
|
lines = append(lines, makeLine(err.Err.Error(), level))
|
||||||
|
@ -100,21 +112,3 @@ func makeLines(errs []error, level int) []string {
|
||||||
}
|
}
|
||||||
return lines
|
return lines
|
||||||
}
|
}
|
||||||
|
|
||||||
func buildError(err error, level int) string {
|
|
||||||
switch err := err.(type) {
|
|
||||||
case nil:
|
|
||||||
return makeLine("<nil>", level)
|
|
||||||
case *nestedError:
|
|
||||||
lines := make([]string, 0, 1+len(err.Extras))
|
|
||||||
if err.Err != nil {
|
|
||||||
lines = append(lines, makeLine(err.Err.Error(), level))
|
|
||||||
}
|
|
||||||
if extras := makeLines(err.Extras, level+1); len(extras) > 0 {
|
|
||||||
lines = append(lines, extras...)
|
|
||||||
}
|
|
||||||
return strings.Join(lines, "\n")
|
|
||||||
default:
|
|
||||||
return makeLine(err.Error(), level)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
package error
|
package err
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"strings"
|
"strings"
|
||||||
|
@ -6,6 +6,7 @@ import (
|
||||||
"github.com/yusing/go-proxy/internal/utils/strutils/ansi"
|
"github.com/yusing/go-proxy/internal/utils/strutils/ansi"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
//nolint:errname
|
||||||
type withSubject struct {
|
type withSubject struct {
|
||||||
Subject string `json:"subject"`
|
Subject string `json:"subject"`
|
||||||
Err error `json:"err"`
|
Err error `json:"err"`
|
||||||
|
@ -18,23 +19,26 @@ func highlight(subject string) string {
|
||||||
}
|
}
|
||||||
|
|
||||||
func PrependSubject(subject string, err error) error {
|
func PrependSubject(subject string, err error) error {
|
||||||
switch err := err.(type) {
|
if err == nil {
|
||||||
case nil:
|
|
||||||
return nil
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
//nolint:errorlint
|
||||||
|
switch err := err.(type) {
|
||||||
case *withSubject:
|
case *withSubject:
|
||||||
return err.Prepend(subject)
|
return err.Prepend(subject)
|
||||||
case Error:
|
case Error:
|
||||||
return err.Subject(subject)
|
return err.Subject(subject)
|
||||||
default:
|
}
|
||||||
return &withSubject{subject, err}
|
return &withSubject{subject, err}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
func (err withSubject) Prepend(subject string) *withSubject {
|
func (err *withSubject) Prepend(subject string) *withSubject {
|
||||||
|
clone := *err
|
||||||
if subject != "" {
|
if subject != "" {
|
||||||
err.Subject = subject + subjectSep + err.Subject
|
clone.Subject = subject + subjectSep + clone.Subject
|
||||||
}
|
}
|
||||||
return &err
|
return &clone
|
||||||
}
|
}
|
||||||
|
|
||||||
func (err *withSubject) Is(other error) bool {
|
func (err *withSubject) Is(other error) bool {
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
package error
|
package err
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -19,12 +20,12 @@ func Errorf(format string, args ...any) Error {
|
||||||
return &baseError{fmt.Errorf(format, args...)}
|
return &baseError{fmt.Errorf(format, args...)}
|
||||||
}
|
}
|
||||||
|
|
||||||
func From(err error) Error {
|
func From(err error) (e Error) {
|
||||||
if err == nil {
|
if err == nil {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
if err, ok := err.(Error); ok {
|
if errors.As(err, &e) {
|
||||||
return err
|
return e
|
||||||
}
|
}
|
||||||
return &baseError{err}
|
return &baseError{err}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
package homepage
|
package homepage
|
||||||
|
|
||||||
type (
|
type (
|
||||||
|
//nolint:recvcheck
|
||||||
Config map[string]Category
|
Config map[string]Category
|
||||||
Category []*Item
|
Category []*Item
|
||||||
|
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
|
//nolint:zerologlint
|
||||||
package logging
|
package logging
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
|
|
@ -81,8 +81,8 @@ func (ri *realIP) setRealIP(req *http.Request) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
var realIPs = req.Header.Values(ri.Header)
|
realIPs := req.Header.Values(ri.Header)
|
||||||
var lastNonTrustedIP string
|
lastNonTrustedIP := ""
|
||||||
|
|
||||||
if len(realIPs) == 0 {
|
if len(realIPs) == 0 {
|
||||||
ri.AddTracef("no real ip found in header %s", ri.Header).WithRequest(req)
|
ri.AddTracef("no real ip found in header %s", ri.Header).WithRequest(req)
|
||||||
|
|
|
@ -45,10 +45,14 @@ func newNotifProvider[T Provider](cfg map[string]any) (Provider, E.Error) {
|
||||||
return client, nil
|
return client, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func formatError(p Provider, err error) error {
|
||||||
|
return fmt.Errorf("%s error: %w", p.Name(), err)
|
||||||
|
}
|
||||||
|
|
||||||
func notifyProvider(ctx context.Context, provider Provider, msg *LogMessage) error {
|
func notifyProvider(ctx context.Context, provider Provider, msg *LogMessage) error {
|
||||||
body, err := provider.MakeBody(msg)
|
body, err := provider.MakeBody(msg)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("%s error: %w", provider.Name(), err)
|
return formatError(provider, err)
|
||||||
}
|
}
|
||||||
req, err := http.NewRequestWithContext(
|
req, err := http.NewRequestWithContext(
|
||||||
ctx,
|
ctx,
|
||||||
|
@ -57,7 +61,7 @@ func notifyProvider(ctx context.Context, provider Provider, msg *LogMessage) err
|
||||||
body,
|
body,
|
||||||
)
|
)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("%s error: %w", provider.Name(), err)
|
return formatError(provider, err)
|
||||||
}
|
}
|
||||||
|
|
||||||
req.Header.Set("Content-Type", provider.MIMEType())
|
req.Header.Set("Content-Type", provider.MIMEType())
|
||||||
|
@ -67,7 +71,7 @@ func notifyProvider(ctx context.Context, provider Provider, msg *LogMessage) err
|
||||||
|
|
||||||
resp, err := http.DefaultClient.Do(req)
|
resp, err := http.DefaultClient.Do(req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("%s error: %w", provider.Name(), err)
|
return formatError(provider, err)
|
||||||
}
|
}
|
||||||
|
|
||||||
defer resp.Body.Close()
|
defer resp.Body.Close()
|
||||||
|
|
|
@ -174,7 +174,9 @@ func (r *HTTPRoute) addToLoadBalancer() {
|
||||||
lbTask.OnCancel("remove lb from routes", func() {
|
lbTask.OnCancel("remove lb from routes", func() {
|
||||||
routes.DeleteHTTPRoute(r.LoadBalance.Link)
|
routes.DeleteHTTPRoute(r.LoadBalance.Link)
|
||||||
})
|
})
|
||||||
lb.Start(lbTask)
|
if err := lb.Start(lbTask); err != nil {
|
||||||
|
panic(err) // should always return nil
|
||||||
|
}
|
||||||
linked = &HTTPRoute{
|
linked = &HTTPRoute{
|
||||||
ReverseProxyEntry: &entry.ReverseProxyEntry{
|
ReverseProxyEntry: &entry.ReverseProxyEntry{
|
||||||
Raw: &route.RawEntry{
|
Raw: &route.RawEntry{
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
|
//nolint:goconst
|
||||||
package types
|
package types
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
|
|
@ -96,16 +96,16 @@ func (w *UDPForwarder) readFromListener(buf *UDPBuf) (srcAddr *net.UDPAddr, err
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
func (dst *UDPConn) read() (err error) {
|
func (conn *UDPConn) read() (err error) {
|
||||||
switch dstConn := dst.conn.(type) {
|
switch dstConn := conn.conn.(type) {
|
||||||
case *net.UDPConn:
|
case *net.UDPConn:
|
||||||
dst.buf.n, dst.buf.oobn, _, _, err = dstConn.ReadMsgUDP(dst.buf.data, dst.buf.oob)
|
conn.buf.n, conn.buf.oobn, _, _, err = dstConn.ReadMsgUDP(conn.buf.data, conn.buf.oob)
|
||||||
default:
|
default:
|
||||||
dst.buf.n, err = dstConn.Read(dst.buf.data[:dst.buf.n])
|
conn.buf.n, err = dstConn.Read(conn.buf.data[:conn.buf.n])
|
||||||
dst.buf.oobn = 0
|
conn.buf.oobn = 0
|
||||||
}
|
}
|
||||||
if err == nil {
|
if err == nil {
|
||||||
logger.Debug().Msgf("read from dst %s success (n: %d, oobn: %d)", dst.DstAddrString(), dst.buf.n, dst.buf.oobn)
|
logger.Debug().Msgf("read from dst %s success (n: %d, oobn: %d)", conn.DstAddrString(), conn.buf.n, conn.buf.oobn)
|
||||||
}
|
}
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
@ -118,17 +118,17 @@ func (w *UDPForwarder) writeToSrc(srcAddr *net.UDPAddr, buf *UDPBuf) (err error)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
func (dst *UDPConn) write() (err error) {
|
func (conn *UDPConn) write() (err error) {
|
||||||
switch dstConn := dst.conn.(type) {
|
switch dstConn := conn.conn.(type) {
|
||||||
case *net.UDPConn:
|
case *net.UDPConn:
|
||||||
dst.buf.n, dst.buf.oobn, err = dstConn.WriteMsgUDP(dst.buf.data[:dst.buf.n], dst.buf.oob[:dst.buf.oobn], nil)
|
conn.buf.n, conn.buf.oobn, err = dstConn.WriteMsgUDP(conn.buf.data[:conn.buf.n], conn.buf.oob[:conn.buf.oobn], nil)
|
||||||
if err == nil {
|
if err == nil {
|
||||||
logger.Debug().Msgf("write to dst %s success (n: %d, oobn: %d)", dst.DstAddrString(), dst.buf.n, dst.buf.oobn)
|
logger.Debug().Msgf("write to dst %s success (n: %d, oobn: %d)", conn.DstAddrString(), conn.buf.n, conn.buf.oobn)
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
_, err = dstConn.Write(dst.buf.data[:dst.buf.n])
|
_, err = dstConn.Write(conn.buf.data[:conn.buf.n])
|
||||||
if err == nil {
|
if err == nil {
|
||||||
logger.Debug().Msgf("write to dst %s success (n: %d)", dst.DstAddrString(), dst.buf.n)
|
logger.Debug().Msgf("write to dst %s success (n: %d)", conn.DstAddrString(), conn.buf.n)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -149,7 +149,7 @@ func extractFields(t reflect.Type) []reflect.StructField {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
var fields []reflect.StructField
|
var fields []reflect.StructField
|
||||||
for i := 0; i < t.NumField(); i++ {
|
for i := range t.NumField() {
|
||||||
field := t.Field(i)
|
field := t.Field(i)
|
||||||
if !field.IsExported() {
|
if !field.IsExported() {
|
||||||
continue
|
continue
|
||||||
|
|
|
@ -32,6 +32,7 @@ func ToLowerNoSnake(s string) string {
|
||||||
return strings.ToLower(strings.ReplaceAll(s, "_", ""))
|
return strings.ToLower(strings.ReplaceAll(s, "_", ""))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//nolint:intrange
|
||||||
func LevenshteinDistance(a, b string) int {
|
func LevenshteinDistance(a, b string) int {
|
||||||
if a == b {
|
if a == b {
|
||||||
return 0
|
return 0
|
||||||
|
|
|
@ -41,7 +41,6 @@ func (mon *RawHealthMonitor) CheckHealth() (result *health.HealthCheckResult, er
|
||||||
}
|
}
|
||||||
if dialErr != nil {
|
if dialErr != nil {
|
||||||
result.Detail = dialErr.Error()
|
result.Detail = dialErr.Error()
|
||||||
/* trunk-ignore(golangci-lint/nilerr) */
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
conn.Close()
|
conn.Close()
|
||||||
|
|
Loading…
Add table
Reference in a new issue