Migrate lint to v2 and add exhaustive check#224
Open
RodriFS wants to merge 1 commit into
Open
Conversation
e63003a to
e31bc6e
Compare
09d90ef to
bf281cd
Compare
e31bc6e to
c377310
Compare
c377310 to
117700d
Compare
Contributor
There was a problem hiding this comment.
Pull request overview
This PR updates the Go linting setup to golangci-lint v2 (including enabling exhaustive), adjusts code to satisfy new lint rules (notably around context usage), and updates project documentation to reflect directory/script changes and provide daemon usage guidance.
Changes:
- Migrate
daemon/.golangci.ymlto the golangci-lint v2 configuration format and enable additional linters (includingexhaustive). - Thread
context.Contextinto RPC server and database startup/cleanup paths. - Update root and daemon READMEs plus
.justfiledefaults to match the current docker/dev workflow.
Reviewed changes
Copilot reviewed 13 out of 13 changed files in this pull request and generated 11 comments.
Show a summary per file
| File | Description |
|---|---|
| README.md | Updates local-dev docker workflow instructions and dev alias sourcing path. |
| daemon/rpc/server.go | Adds context-aware listener creation via net.ListenConfig. |
| daemon/rpc/server_test.go | Updates test to pass a context into ListenAndServe. |
| daemon/README.md | Adds local dev guide for running the daemon and creating swaps. |
| daemon/lightning/lnd/lnd.go | Lint-driven updates (ReplaceAll, exhaustive suppression, enum handling). |
| daemon/database/database.go | Adds context to DB ctor and uses it for lsof/kill cleanup; normalizes error strings. |
| daemon/database/database_test.go | Passes test context into DB constructor. |
| daemon/database/cli/main.go | Threads CLI context into DB startup. |
| daemon/daemon/daemon.go | Passes context into RPC server startup. |
| daemon/cmd/main.go | Passes context into DB ctor; removes liquid flag definition. |
| daemon/bitcoin/helpers.go | Normalizes error message casing. |
| daemon/.golangci.yml | Migrates to golangci-lint v2 config and enables exhaustive. |
| .justfile | Changes default docker compose profile to mempool-btc. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
67
to
+70
| By sourcing [`server-backend/dev/dev-aliases.sh`](server-backend/dev/dev-aliases.sh) you can get access to some useful commands, e.g.: | ||
|
|
||
| ```bash | ||
| source server-backend/dev/dev-aliases.sh | ||
| source docker/dev-aliases.sh |
Comment on lines
295
to
297
| log.WithField("invoice", invoice).Debug("New TrackPaymentV2 event") | ||
| // nolint: exhaustive // lnrpc.Payment_UNKNOWN is deprecated, so we need to ignore either the exhaustive check or the deprecated check. | ||
| switch invoice.Status { |
Comment on lines
73
to
77
| if !keepAlive { | ||
| if err := postgres.Stop(); err != nil { | ||
| if errors.Is(err, embeddedpostgres.ErrServerNotStarted) && isPostgresRunning(port) { | ||
| killPostgres(port) | ||
| if errors.Is(err, embeddedpostgres.ErrServerNotStarted) && isPostgresRunning(ctx, port) { | ||
| killPostgres(ctx, port) | ||
|
|
Comment on lines
161
to
165
| func (d *Database) close() error { | ||
| db, err := d.orm.DB() | ||
| if err != nil { | ||
| return fmt.Errorf("Could not get database connection: %w", err) | ||
| return fmt.Errorf("could not get database connection: %w", err) | ||
| } |
Comment on lines
+218
to
222
| out, err := exec.CommandContext(ctx, "lsof", "-i", fmt.Sprintf(":%d", port), "-t").Output() | ||
| if err == nil { | ||
| pid := strings.TrimSpace(string(out)) | ||
| _ = exec.Command("kill", "-9", pid).Run() | ||
| _ = exec.CommandContext(ctx, "kill", "-9", pid).Run() | ||
| } |
| cd server-backend/dev | ||
| docker compose up | ||
| cd docker | ||
| docker compose up <profile> |
| ```bash | ||
| server-backend/dev/nodes-setup.sh | ||
| cd docker | ||
| nodes-setup.sh |
| 2. Run the daemon | ||
|
|
||
| ```bash | ||
| just run-daemon |
|
|
||
| ```bash | ||
| just user-lncli addinvoice 200000 # Copy the payreq | ||
| just run swap in --payreq <payreq> |
| 4. Create a swap out | ||
|
|
||
| ```bash | ||
| just run swap out --address bcrt1q94gs370gfjut9d75ss3j7m8l7m3phs06nlqd8n --amt 200000 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR migrates to golint-v2, adds an exhaustive check for enums and fixes all linter errors.
Also, it updates the README files to be in line file movements and also added a bit of a guide to the daemon readme so a new user can easily create a swap.