# Fix "strings.Title Has Been Deprecated" (SA1019) in a Go CLI

Yes. An agent runs staticcheck, replaces every strings.Title with golang.org/x/text/cases, proves the output is unchanged for your inputs and opens a PR.

[Run this on Rush](https://cloud.getrush.ai/run/fix-strings-title-is-deprecated/strings/). Opens the console with this prompt ready to send, in a Project that has your repository.

## What the agent does

The agent clones the repository into its own cloud sandbox and runs the checks before changing anything. In a Go CLI like jsiebens/hashi-up, which installs HashiCorp tools on remote hosts over SSH, `go.mod` declares `go 1.19` and lists `golang.org/x/text v0.3.8` as an indirect dependency, and `.github/workflows/ci-only.yaml` builds with Go 1.19. `go build ./...` and `go vet ./...` are clean. `staticcheck ./...` is not: it prints 14 lines of `strings.Title has been deprecated since Go 1.18 and an alternative has been available since Go 1.0: The rule Title uses for word boundaries does not handle Unicode punctuation properly. Use golang.org/x/text/cases instead. (SA1019)` at `cmd/command.go:46` and `:47`, `cmd/get.go:30`, `:31` and `:35`, `cmd/service.go:17`, `:18` and `:53` (two calls on each of those three lines) and `cmd/uninstall.go:17`, `:18` and `:53`, plus three `io/ioutil` and one `golang.org/x/crypto/ssh/terminal` deprecation it leaves for another change.

Then it reads what the calls do. `cmd/command.go` builds one subcommand per product (`consul`, `nomad`, `vault`, `boundary`, `consul-template`, and so on) and uses `strings.Title(name)` for the `Short` and `Long` help text, `Install or download Consul`. `cmd/service.go` does the same for the `start`, `stop`, `restart` and `reload` actions, `Restart Consul systemd service on a server via SSH`, and prints `Restarting Consul ...` while it works. Every input is a lowercase ASCII product or action name, so the deprecation's Unicode caveat does not bite here, but a linter that fails CI does.

The fix is one helper. The agent adds `cmd/title.go` with `func title(s string) string { return cases.Title(language.English).String(s) }`, replaces the 14 `strings.Title(` calls with `title(`, and removes the now unused `"strings"` import from the four files, which the first rebuild flags as `"strings" imported and not used`. `go mod tidy` moves `golang.org/x/text` from the indirect block to a direct requirement at the same `v0.3.8`, so no new module is downloaded. `go build ./...` and `go vet ./...` pass again, and `staticcheck ./...` reports only the `io/ioutil` and `ssh/terminal` lines that were there before.

It proves the text did not change. A table test compares `title` with `strings.Title` for the 19 product and action names the commands use, from `consul` to `consul-template` and `uninstall`, and passes. The pull request also states the one difference the reviewer should know: `cases.Title` lowercases the rest of each word, so an input like `hashiCorp` would come out `Hashicorp` where `strings.Title` kept `HashiCorp`; none of this program's inputs has a capital after the first letter. Running `hashi-up consul get --help` and `hashi-up nomad install --help` afterwards prints the same `Download Consul on your local machine` and `Install Nomad on a server via SSH` as before.

## Start it with one API call

`POST https://api.phoenix.so/o/{org}/sessions`

```json
{
  "agent": "claude",
  "input": "CI fails on staticcheck with SA1019: strings.Title has been deprecated. Read go.mod and run go build, go vet and staticcheck first, and quote every SA1019 line. Replace each strings.Title call with cases.Title from golang.org/x/text/cases through one small helper, remove imports that become unused, run go mod tidy and show the build, vet and staticcheck results afterwards. Add a test that compares the helper with strings.Title for every string the program actually passes, and state any input where the two would differ. Leave other deprecations staticcheck reports as they are and list them. Open a pull request that quotes the before and after.",
  "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

What comes back is a pull request touching the four files under `cmd/` that called `strings.Title`, a new `cmd/title.go` with the helper and its test, and `go.mod` with `golang.org/x/text` promoted to a direct dependency at its existing version. The description quotes the 14 SA1019 lines from the first staticcheck run, the clean build and vet, and the second staticcheck run with only the unrelated `io/ioutil` and `ssh/terminal` lines left.

A reviewer checks that every replaced call feeds a lowercase ASCII name, reads the one sentence about `cases.Title` lowercasing the rest of a word, and sees the table test passing for the 19 names in use. The run's record has each command and its output, so the `--help` text before and after can be compared from the transcript rather than from the description.

## Run it on every failed lint job

Add an automation to the Project with this prompt and a `webhook` trigger. A handler on your server that receives GitHub's `workflow_run` event for the lint job, or a Grafana alert rule on the CI failure, calls the trigger's URL with the `Authorization: Bearer` header the trigger needs, and one run starts per failure with the payload after the prompt; give the trigger's URL an `Idempotency-Key` made from the workflow run id so a redelivery starts nothing twice.

The same prompt fits a `schedule` trigger that runs staticcheck each Monday in your `timezone`, before the Go release that turns a deprecation into a removal: a week with nothing to report opens nothing.

## Why run it on Rush?

A deprecation warning is a decision waiting to be made, and the cost of making it is reading every call site. The agent does that in its sandbox: it runs staticcheck, opens each of the 14 lines, finds that all of them title-case a product or action name, and writes the replacement once. Every command and its output stays in the run's record, so the pull request shows the lint output going from 14 lines to none for this rule.

The replacement is not quite a synonym, and that is the part a laptop fix skips. `cases.Title` folds the rest of each word to lowercase, so the agent adds a test over the program's real inputs and names the case where the two functions would differ, which is what a reviewer needs to merge a change to user-visible help text without reading the `x/text` source.

## Frequently asked questions

### Why was strings.Title deprecated?

Its word-boundary rule is byte-based and gets Unicode punctuation wrong, so Go 1.18 marked it deprecated and pointed at `golang.org/x/text/cases`, which uses the Unicode casing rules for a given language. The function still exists and still compiles; only the linter objects.

### Does this add a dependency?

In this repository, no: `golang.org/x/text` was already in `go.mod` as an indirect requirement, and `go mod tidy` makes it direct at the same version. In a module that does not have it yet, `go get golang.org/x/text` adds one well-known module, and the pull request says so.

### Will the output change for my strings?

For lowercase ASCII words, no, and the agent's test proves it for the strings your program passes. For a word with a capital after its first letter, `cases.Title` lowercases it where `strings.Title` did not; the agent states that difference in the pull request so you can decide whether any input needs `cases.Title(language.English, cases.NoLower)`.

### Why not silence SA1019 with a lint comment?

A `//lint:ignore` keeps the deprecated call and its Unicode bug. With 14 identical calls and a one-line helper, the replacement is smaller than the comments would be.

## More jobs like this: Fix a bug from an alert

- [Fix "'Switch' is not exported from 'react-router-dom'" after upgrading to React Router 6](https://getrush.ai/run/fix-switch-is-not-exported-from-react-router-dom/react-router/)
- [Fix "It looks like you're trying to use `tailwindcss` directly as a PostCSS plugin" after Tailwind CSS 4](https://getrush.ai/run/fix-tailwindcss-directly-as-postcss-plugin/tailwind/)
- [Fix "ImportError: cannot import name 'Filters' from 'telegram.ext'"](https://getrush.ai/run/fix-telegram-ext-filters-import-error/python-telegram-bot/)
- [Fix "Provider registry.terraform.io/hashicorp/template v2.2.0 does not have a package available for your current platform, darwin_arm64"](https://getrush.ai/run/fix-template-provider-darwin-arm64/terraform/)
- [Fix "AttributeError: module 'tensorflow' has no attribute 'Session'" in TensorFlow 2](https://getrush.ai/run/fix-tensorflow-session-attribute-error/tensorflow/)
- [Fix ClientClosedError: The client is closed in a Node.js Redis App](https://getrush.ai/run/fix-the-client-is-closed-error/node-redis/)

## Keep reading

- [How a Rush run works on your repository, from request to pull request](https://getrush.ai/cloud/)
- [Compare cloud agents, agent sandboxes and AI code review](https://getrush.ai/compare/)
- [Rush pricing: Free, Pro and Max](https://getrush.ai/pricing/)
