multi: prepare for new non-constant string rule

In preparation for the next commit which bumps golang to a newer
version, we want to make some code changes that would otherwise render
some log-related calls problematic. With go1.24 a new govet rule was
added that disallows non-constant strings (i.e including a tag like
"%s") in calls to printf. See more in the related issue
https://github.com/golang/go/issues/60529.
This commit is contained in:
George Tsagkarelis 2025-09-18 11:55:00 +02:00
parent bce4c049a9
commit 3ccfc5231b
No known key found for this signature in database
GPG key ID: E08DEA9B12B66AF6
5 changed files with 16 additions and 15 deletions

View file

@ -270,12 +270,10 @@ out:
n.EnsureConnected(t, n.Alice, n.Bob)
logLine := fmt.Sprintf(
"STARTING ============ %v ============\n", testCase,
)
logLine := "STARTING ============ %v ============\n"
n.Alice.AddToLog(logLine)
n.Bob.AddToLog(logLine)
n.Alice.AddToLog(logLine, testCase)
n.Bob.AddToLog(logLine, testCase)
return nil
}

View file

@ -364,7 +364,7 @@ func (p *rpcProxy) makeDirector(allowLitRPC bool) func(ctx context.Context,
// gRPC server.
handled, conn, err := p.subServerMgr.GetRemoteConn(requestURI)
if err != nil {
return outCtx, nil, status.Errorf(
return outCtx, nil, status.Error(
codes.Unavailable, err.Error(),
)
}

View file

@ -76,8 +76,12 @@ func RPCErrString(req *lnrpc.RPCMiddlewareRequest, format string,
},
}
if len(args) > 0 {
format = fmt.Sprintf(format, args...)
}
if format != "" {
feedback.Error = fmt.Sprintf(format, args...)
feedback.Error = format
}
return resp, nil

View file

@ -264,18 +264,20 @@ func (s *Manager) SetErrored(name string, errStr string,
s.mu.Lock()
defer s.mu.Unlock()
err := fmt.Sprintf(errStr, params...)
if len(params) > 0 {
errStr = fmt.Sprintf(errStr, params...)
}
log.Debugf("Setting the %s sub-server as errored: %s", name, err)
log.Debugf("Setting the %s sub-server as errored: %s", name, errStr)
ss, ok := s.subServers[name]
if !ok {
return
}
log.Errorf("could not start the %s sub-server: %s", name, err)
log.Errorf("could not start the %s sub-server: %s", name, errStr)
ss.running = false
ss.err = err
ss.err = errStr
ss.customStatus = ""
}

View file

@ -431,10 +431,7 @@ func (g *LightningTerminal) start(ctx context.Context) error {
var err error
accountServiceErrCallback := func(err error) {
g.statusMgr.SetErrored(
subservers.ACCOUNTS,
err.Error(),
)
g.statusMgr.SetErrored(subservers.ACCOUNTS, err.Error())
log.Errorf("Error thrown in the accounts service, keeping "+
"litd running: %v", err,