---
title: "byte-string-write"
description: "Detect byte slices converted to strings for io.WriteString."
image: "https://strider.gempir.com/og.png"
---

> Documentation Index
> Fetch the complete documentation index at: https://strider.gempir.com/llms.txt
> Use this file to discover all available pages before exploring further.

# byte-string-write

**Default severity:** `warning`

`io.WriteString(writer, string(bytes))` allocates and copies the byte slice
before writing it. The writer already accepts bytes through `Write`, so write
the original slice directly.

## Bad

```go
_, err := io.WriteString(writer, string(bytes))
```

## Good

```go
_, err := writer.Write(bytes)
```

Source: https://strider.gempir.com/analyzers/byte-string-write/index.mdx
