# cURL with Basic auth in Go

Paste a curl command that uses Basic auth and get Go code using net/http. Toolpaper also detects secrets and offers a one-click redaction before sharing.

## Example

```bash
curl https://api.example.com/me \
  -u alice:s3cret
```

## What the converter handles

- -u user:pass is decoded and re-emitted as an idiomatic net/http auth primitive rather than a hand-rolled base64 header.
- Secrets are visible in the parsed request. Use the Clean panel's redact-and-diff flow before you paste the command anywhere.
- Shareable links Base64-encode the input — they never leave your browser, and cleaned versions produce different links.

## Common mistakes

- Hard-coding user:pass into source instead of reading from env vars — the generated snippet marks credentials so you notice.
- Not rotating a leaked credential because "it's only in a screenshot" — screenshots get OCR'd, redact first.
- Trusting HTTPS alone for API keys in query strings — proxies log URLs. Prefer headers, which the converter defaults to.

## FAQ

### How is Basic auth rendered in Go?

-u user:pass becomes an idiomatic Basic auth call — auth=(user, pass) in Python, SetBasicAuth in Go, .setBasicAuth in Java.

### Can I redact the secret before sharing?

Yes. Open the Clean panel — Toolpaper detects Bearer tokens, Basic credentials, and common API-key patterns and replaces them with <REDACTED> in a diffable view.

### Does anything leave my browser?

No. Parsing, redaction, and generation are 100% client-side.

---

Source: https://toolpaper.manavdev.site/how-to/curl-basic-auth-in-go · Language hub: https://toolpaper.manavdev.site/curl-to-go