Skip to content

Comments

Fix lint error when go.mod is not present in root#18

Open
TxCorpi0x wants to merge 6 commits intomasterfrom
mehdi/fix-go-work-crust-lint
Open

Fix lint error when go.mod is not present in root#18
TxCorpi0x wants to merge 6 commits intomasterfrom
mehdi/fix-go-work-crust-lint

Conversation

@TxCorpi0x
Copy link
Contributor

@TxCorpi0x TxCorpi0x commented Feb 17, 2026

Description

This pull request significantly updates the Go linter logic in build/golang/lint.go to better support repositories using a go.work workspace. The new approach parses the go.work file to identify all modules, filters out those without Go code, and then runs the linter on the relevant modules in a single command. This streamlines linting for multi-module repositories and improves logging and error handling.

Go workspace and linter improvements:

  • Added logic to detect and parse the go.work file using the new parseGoWork function, which runs go work edit -json and extracts module paths. This enables linting across all modules in a workspace.
  • Updated the linting process to filter out modules that do not contain Go code, ensuring the linter only runs on relevant modules and providing clearer log messages.
  • Changed the linter invocation to run a single golangci-lint command from the repository root, passing all valid module paths as arguments, rather than running the linter separately for each module.

Dependency and import changes:

  • Added the encoding/json import to support parsing the output of go work edit -json.

FIXES

level=warning msg="[linters_context] running gomodguard failed: unable to read module file go.mod: current working directory must have a go.mod file: if you are not using go modules it is suggested to disable this linter"
level=error msg="[linters_context] typechecking error: pattern ./...: directory prefix . does not contain modules listed in go.work or their selected dependencies"
0 issues.

Reviewers checklist:

  • Try to write more meaningful comments with clear actions to be taken.
  • Nit-picking should be unblocking. Focus on core issues.

Authors checklist

  • Provide a concise and meaningful description
  • Review the code yourself first, before making the PR.
  • Annotate your PR in places that require explanation.
  • Think and try to split the PR to smaller PR if it is big.

This change is Reviewable

@TxCorpi0x TxCorpi0x requested a review from a team as a code owner February 17, 2026 08:14
@TxCorpi0x TxCorpi0x requested review from masihyeganeh, metalarm10, miladz68 and ysv and removed request for a team February 17, 2026 08:14
Copy link

@miladz68 miladz68 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@miladz68 reviewed 4 files and all commit messages, and made 1 comment.
Reviewable status: all files reviewed, 1 unresolved discussion (waiting on masihyeganeh, metalarm10, TxCorpi0x, and ysv).


build/golang/lint.go line 64 at r2 (raw file):

	}

	workFilePath := filepath.Join(repoPath, "go.work")

have you tested this against tx-chain ? i was not able to get it to run it successfully.

Copy link
Contributor Author

@TxCorpi0x TxCorpi0x left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@TxCorpi0x made 1 comment.
Reviewable status: 3 of 4 files reviewed, 1 unresolved discussion (waiting on masihyeganeh, metalarm10, miladz68, and ysv).


build/golang/lint.go line 64 at r2 (raw file):

Previously, miladz68 (milad) wrote…

have you tested this against tx-chain ? i was not able to get it to run it successfully.

The fix has changed and the code is refactored, tested with tx-chain, tx-bridge-xrpl, tx-crust itself

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants