-
Notifications
You must be signed in to change notification settings - Fork 18.8k
Closed
Labels
Description
Go version
1.22
Output of go env in your module/workspace:
Whatever go.dev/play has.What did you do?
https://go.dev/play/p/lRtKx16rXk1
package main
import (
"fmt"
"strings"
)
func main() {
lines := []string{
"line 1",
"",
"line 2",
"",
"line 3",
"",
}
joined := strings.Join(lines[0:4], "\n")
foundCount := 0
for _, c := range joined {
if c == 0x0a {
foundCount += 1
}
}
fmt.Printf("found %d line feeds, expected 4", foundCount)
}What did you see happen?
strings.Join skipped adding the intended final joining character.
What did you expect to see?
strings.Join would join all elements passed to it with the provided joining character.
Reactions are currently unavailable