Thanks to visit codestin.com
Credit goes to pkg.go.dev

strings

package
v1.20.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 5, 2026 License: BSD-2-Clause Imports: 2 Imported by: 0

Documentation

Rendered for js/wasm

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Clone added in v1.20.0

func Clone(s string) string

func Count

func Count(s, sep string) int

func Index

func Index(s, sep string) int

func IndexByte

func IndexByte(s string, c byte) int

func LastIndex

func LastIndex(s, sep string) int

func Repeat added in v1.20.0

func Repeat(s string, count int) string

Repeat is the go1.19 implementation of strings.Repeat.

In the go1.20 implementation, the function was changed to use chunks that are 8KB in size to improve speed and cache access. This change is faster when running native Go code. However, for GopherJS, the change is much slower than the go1.19 implementation.

The go1.20 change made tests like encoding/pem TestCVE202224675 take significantly longer to run for GopherJS. go1.19 concatenates 24 times and the test takes about 8 seconds. go1.20 concatenates about 15000 times and can take over a hour.

We can't use `js.InternalObject(s).Call("repeat", count).String()` because JS performs additional UTF-8 escapes meaning tests like hash/adler32 TestGolden will fail because the wrong input is created.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL