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.
Go version
1.22
Output of
go envin your module/workspace:What did you do?
https://go.dev/play/p/lRtKx16rXk1
What did you see happen?
strings.Joinskipped adding the intended final joining character.What did you expect to see?
strings.Joinwould join all elements passed to it with the provided joining character.