All jobs

Replace Deprecated golint With revive, go vet and staticcheck in a Go Project

Yes. An agent swaps golint for revive, go vet and staticcheck, compares the findings before and after, fixes what is safe, and opens a pull request.

Run this on RushOpens the console with this prompt ready to send, in a Project that has your repository.

What the agent does

golint is frozen and deprecated, and its maintainers pointed users to go vet and staticcheck. Projects still call it from Makefiles written years ago, and it still installs and runs, so nothing forces the change. What it costs is easy to miss: golint checks style only, from syntax alone, and never type-checks the code. botherder/androidqf shows the gap. Its Makefile has a lint target that runs golint ./.... A revive.toml with 23 enabled rules sits in the repository root, with #[rule.exported] commented out, and nothing invokes it. The intention to move is already written down, and the agent's job is to finish it and show what changes.

It begins with a baseline. golint ./... prints 59 findings for this repository. Fifty-seven are the same sentence about an exported name that should have a comment or be unexported. One asks for a different comment form in adb/adb.go, and one objects to the blank embed import in assets/assets_linux.go. Then it runs revive -config revive.toml ./... with the project's own file: five findings, each a missing package comment. The drop from 59 to 5 is the commented-out exported rule doing what its author intended, and the agent says so instead of presenting it as an improvement in the code.

Type-checking linters need the program to compile, and here it does not compile from a fresh clone. assets/assets_linux.go embeds a file named adb that .gitignore excludes and that make linux downloads from Google's platform-tools archive. Without it, go vet and staticcheck both stop at pattern adb: no matching files found. golint never noticed, because it never looked that far. The agent gives the lint target a prerequisite that makes the embed resolvable, an empty placeholder when the real binary is absent, and documents it.

With that in place the new tools have something to say. staticcheck reports nothing. go vet reports main.go:26:3: missing ... in args forwarded to printf-like function: fatalIfError takes args ...interface{} and calls fatal(format, args), so every fatal error message is formatted with a slice where the values should be. The fix is three characters, and it is a real bug that 59 style findings sat on top of. The agent fixes it in its own commit, adds the five package comments, and rewrites the lint target to run go vet, revive with the config file, and staticcheck, with the two external tools installed by go install at pinned versions.

Start it with one API call

POST https://api.phoenix.so/o/{org}/sessions with this body:

{
  "agent": "claude",
  "input": "Replace golint in this Go project with maintained tools: revive for style, plus go vet and staticcheck for correctness. First find every place golint is installed or run: Makefile targets, CI workflows, Dockerfiles, scripts, pre-commit hooks, editor settings and contributor docs. Run golint as currently configured and save a count of findings by kind as the baseline. Check whether the repository already has a revive, staticcheck or golangci-lint configuration; use it if so and do not replace its choices, otherwise create a revive.toml that enables the rules matching golint's defaults. Run revive, go vet ./... and staticcheck ./... and report findings by tool and kind next to the baseline, explaining any large difference by the rule that causes it. If the type-checking tools cannot compile the code from a fresh clone, for example because of go:embed files that are generated or downloaded, make the lint target work without the full build and explain how. Fix findings that are bugs in their own commit with a one-line explanation each. Fix style findings only when the change is mechanical; do not add doc comments to dozens of exported names in this pull request, and do not disable a rule to make the output empty. Update every place found in the first step so they all run the same commands, with tool versions pinned to releases that support the project's Go version. Run the build and the tests if there are any. Open a pull request.",
  "resources": [
    {
      "url": "https://github.com/your-org/your-app"
    }
  ]
}
  1. Get an API key. In the console, open Settings, then API keys, and create a key for your org. Send it in the Authorization header as a Bearer token.
  2. Send the request. POST the body in request.json to https://api.phoenix.so/o/{org}/sessions, with your repository as the resources URL. The run starts in its own cloud sandbox.
  3. Read what came back. Follow the run on its live stream or wait for the run.completed webhook, then read the result and its trajectory.

What comes back

A pull request in separate commits, so each kind of change can be judged alone: the Makefile's lint target and its placeholder step, the bug fix in main.go, and the package comments. The description holds a table with one row per tool and the count of findings by kind, with the golint baseline in the first row. A reader sees at a glance that the style count fell because of a rule the project had already switched off, and that the one new finding is a defect.

It also says what is left alone. androidqf has no test files and its only workflow, release.yaml, builds binaries when a tag is pushed, so no check runs the linters on a pull request. The agent names that as a follow-up and does not add a CI job nobody asked for. It lists the tool versions it pins and the Go version in go.mod they are matched to.

A reviewer reads the main.go change first, since it alters what users see when the tool fails, and then decides whether five package comments are wanted or whether that rule should join exported in being switched off. Either answer is a one-line change to revive.toml.

Run it on every repository whose Makefile calls golint

The tool is deprecated everywhere at once, so sweep for it. Search your organisation's repositories for golint in Makefiles, workflows and scripts. For each hit send POST /o/{org}/sessions with the body above and the repository in resources, adding a request_id that is a UUID v5 of the repository's full name so the sweep can be rerun safely. Runs beyond the key's concurrency limit are created queued and start as slots free.

Give the key a webhook_url to collect the results; each run the key starts reports there when it finishes. The pull requests worth opening first are the ones whose description has a row for go vet or staticcheck that is not empty. Those are the repositories where the old linter was hiding something.

The use case this job follows, with its automation and trigger: Upgrade dependencies weekly.

Why run it on Rush?

Swapping one command for another in a Makefile is quick, and on its own it tells you nothing. The value is in the comparison: the same code through the old tool and the new ones, counted by kind, with the differences explained. Producing that means installing three linters, getting a project to type-check from a clean clone, and reading the output with care. The agent does it in its own sandbox and keeps every command and its output in the session, so the table in the pull request can be traced to the lines that produced it.

It also changes what the migration is for. A team that expects a chore gets back a pull request where one commit fixes a formatting bug in its error path. That finding only exists because the tools are actually run against the code, and it is the kind of result that makes the next repository's migration easier to prioritise.

Frequently asked questions

Is golint deprecated?

Yes. The project is frozen and its repository is archived, and the maintainers recommend go vet and staticcheck in its place. It still installs with go install golang.org/x/lint/golint@latest and still runs, which is why many Makefiles have not been updated.

What is the closest replacement for golint?

revive. It was written as a drop-in successor, implements golint's checks as named rules, and adds a configuration file so a team can switch individual rules on and off. Run without a config it behaves much like golint did; androidqf prints a similar number of findings that way.

Do I need staticcheck as well as revive?

They look for different things. revive is mostly about style and naming. staticcheck and go vet type-check the code and report likely bugs, deprecated API use and suspicious constructs. A project that only replaces golint with revive keeps the same blind spot it had.

Why not golangci-lint?

It is a good choice when you want many linters behind one command and one config, and it can run revive and staticcheck for you. The agent uses it when the repository already has a golangci-lint configuration. Where a project has a revive.toml and a Makefile, it keeps the smaller setup and mentions the alternative.

Will the agent add comments to every exported function?

No. The prompt tells it not to, because 57 generated doc comments are noise in a review and rarely good documentation. It reports the count, respects the project's decision if the rule is already disabled, and leaves writing real documentation as a separate task.

More jobs like this: Upgrade dependencies weekly

Keep reading