Skip to content

Commit 7d9c650

Browse files
committed
linter: fix lint issues after linter update
1 parent c236a15 commit 7d9c650

40 files changed

+136
-90
lines changed

assets/client.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -290,7 +290,8 @@ func getClientConn(config *TapdConfig) (*grpc.ClientConn, error) {
290290
return nil, err
291291
}
292292
mac := &macaroon.Macaroon{}
293-
if err := mac.UnmarshalBinary(macBytes); err != nil {
293+
err = mac.UnmarshalBinary(macBytes)
294+
if err != nil {
294295
return nil, err
295296
}
296297

client.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,8 @@ var (
9393
// Client performs the client side part of swaps. This interface exists to be
9494
// able to implement a stub.
9595
type Client struct {
96+
clientConfig
97+
9698
started uint32 // To be used atomically.
9799
errChan chan error
98100

@@ -107,8 +109,6 @@ type Client struct {
107109

108110
resumeReady chan struct{}
109111
wg sync.WaitGroup
110-
111-
clientConfig
112112
}
113113

114114
// ClientConfig is the exported configuration structure that is required to

cmd/loop/instantout.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,6 @@ func instantOut(ctx *cli.Context) error {
187187
DestAddr: ctx.String("addr"),
188188
},
189189
)
190-
191190
if err != nil {
192191
return err
193192
}
@@ -228,5 +227,6 @@ func listInstantOuts(ctx *cli.Context) error {
228227
}
229228

230229
printRespJSON(resp)
230+
231231
return nil
232232
}

cmd/loop/loopin.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,11 +126,13 @@ func loopIn(ctx *cli.Context) error {
126126

127127
// Validate our label early so that we can fail before getting a quote.
128128
label := ctx.String(labelFlag.Name)
129-
if err := labels.Validate(label); err != nil {
129+
err = labels.Validate(label)
130+
if err != nil {
130131
return err
131132
}
132133

133134
var lastHop []byte
135+
134136
if ctx.IsSet(lastHopFlag.Name) {
135137
lastHopVertex, err := route.NewVertexFromStr(
136138
ctx.String(lastHopFlag.Name),
@@ -207,6 +209,7 @@ func loopIn(ctx *cli.Context) error {
207209

208210
fmt.Printf("Swap initiated\n")
209211
fmt.Printf("ID: %v\n", resp.Id)
212+
210213
if resp.HtlcAddressP2Tr != "" {
211214
fmt.Printf("HTLC address (P2TR): %v\n", resp.HtlcAddressP2Tr)
212215
} else {

cmd/loop/loopout.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,7 @@ func loopOut(ctx *cli.Context) error {
148148
// Otherwise, strings.Split returns a slice of length one with an empty
149149
// element.
150150
var outgoingChanSet []uint64
151+
151152
if ctx.IsSet("channel") {
152153
if ctx.IsSet("asset_id") {
153154
return fmt.Errorf("channel flag is not supported when " +
@@ -166,7 +167,8 @@ func loopOut(ctx *cli.Context) error {
166167

167168
// Validate our label early so that we can fail before getting a quote.
168169
label := ctx.String(labelFlag.Name)
169-
if err := labels.Validate(label); err != nil {
170+
err = labels.Validate(label)
171+
if err != nil {
170172
return err
171173
}
172174

@@ -177,6 +179,7 @@ func loopOut(ctx *cli.Context) error {
177179
}
178180

179181
var destAddr string
182+
180183
var account string
181184
switch {
182185
case ctx.IsSet("addr"):
@@ -338,6 +341,7 @@ func loopOut(ctx *cli.Context) error {
338341
fmt.Printf("Swap initiated\n")
339342
fmt.Printf("ID: %x\n", resp.IdBytes)
340343
fmt.Printf("HTLC address: %v\n", resp.HtlcAddress) // nolint:staticcheck
344+
341345
if resp.ServerMessage != "" {
342346
fmt.Printf("Server message: %v\n", resp.ServerMessage)
343347
}

cmd/loop/main.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,7 @@ func printJSON(resp interface{}) {
140140
if err != nil {
141141
fatal(err)
142142
}
143+
143144
out.WriteString("\n")
144145
_, _ = out.WriteTo(os.Stdout)
145146
}
@@ -446,7 +447,8 @@ func readMacaroon(macPath string) (grpc.DialOption, error) {
446447
}
447448

448449
mac := &macaroon.Macaroon{}
449-
if err = mac.UnmarshalBinary(macBytes); err != nil {
450+
err = mac.UnmarshalBinary(macBytes)
451+
if err != nil {
450452
return nil, fmt.Errorf("unable to decode macaroon: %v", err)
451453
}
452454

cmd/loop/staticaddr.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -417,6 +417,7 @@ func utxosToOutpoints(utxos []string) ([]*looprpc.OutPoint, error) {
417417
if len(utxos) == 0 {
418418
return nil, fmt.Errorf("no utxos specified")
419419
}
420+
420421
for _, utxo := range utxos {
421422
outpoint, err := NewProtoOutPoint(utxo)
422423
if err != nil {
@@ -509,7 +510,8 @@ func staticAddressLoopIn(ctx *cli.Context) error {
509510
)
510511

511512
// Validate our label early so that we can fail before getting a quote.
512-
if err := labels.Validate(label); err != nil {
513+
err = labels.Validate(label)
514+
if err != nil {
513515
return err
514516
}
515517

cost_migration.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ func CalculateLoopOutCost(params *chaincfg.Params, loopOutSwap *loopdb.LoopOut,
2525
paymentFees map[lntypes.Hash]lnwire.MilliSatoshi) (loopdb.SwapCost,
2626
error) {
2727

28-
// First make sure that this swap is actually finished.
28+
// First, make sure that this swap is actually finished.
2929
if loopOutSwap.State().State.IsPending() {
3030
return loopdb.SwapCost{}, fmt.Errorf("swap is not yet finished")
3131
}
@@ -41,8 +41,8 @@ func CalculateLoopOutCost(params *chaincfg.Params, loopOutSwap *loopdb.LoopOut,
4141
}
4242

4343
// The swap hash is given and we don't need to get it from the
44-
// swap invoice, however we'll decode it anyway to get the invoice amount
45-
// that was paid in case we don't have the payment anymore.
44+
// swap invoice, however we'll decode it anyway to get the invoice
45+
// amount that was paid in case we don't have the payment anymore.
4646
_, _, swapHash, swapPaymentAmount, err := swap.DecodeInvoice(
4747
params, loopOutSwap.Contract.SwapInvoice,
4848
)
@@ -195,6 +195,6 @@ func MigrateLoopOutCosts(ctx context.Context, lnd lndclient.LndServices,
195195
return err
196196
}
197197

198-
// Finally mark the migration as done.
198+
// Finally, mark the migration as done.
199199
return db.SetMigration(ctx, costMigrationID)
200200
}

executor.go

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -45,14 +45,13 @@ type executorConfig struct {
4545
//
4646
// TODO(roasbeef): rename to SubSwapper.
4747
type executor struct {
48+
sync.Mutex
49+
executorConfig
50+
4851
wg sync.WaitGroup
4952
newSwaps chan genericSwap
5053
currentHeight uint32
5154
ready chan struct{}
52-
53-
sync.Mutex
54-
55-
executorConfig
5655
}
5756

5857
// newExecutor returns a new swap executor instance.
@@ -80,7 +79,6 @@ func (s *executor) run(mainCtx context.Context,
8079
for {
8180
blockEpochChan, blockErrorChan, err =
8281
s.lnd.ChainNotifier.RegisterBlockEpochNtfn(mainCtx)
83-
8482
if err == nil {
8583
break
8684
}

fsm/fsm.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ func NewStateMachine(states States, observerSize int) *StateMachine {
138138
func NewStateMachineWithState(states States, current StateType,
139139
observerSize int) *StateMachine {
140140

141-
observers := []Observer{}
141+
var observers []Observer
142142
var defaultObserver *CachedObserver
143143

144144
if observerSize > 0 {

0 commit comments

Comments
 (0)