
The algorithm now checks for invalid UTF-8 sequences, which is required by the Go spec. This gets the tests of the unicode/utf8 package to pass. Also add bytes.Equal for Go 1.11, which again is necessary for the unicode/utf8 package.
20 строки
505 Б
Go
20 строки
505 Б
Go
// +build !go1.12
|
|
|
|
package runtime
|
|
|
|
import "internal/bytealg"
|
|
|
|
// The following functions provide compatibility with Go 1.11.
|
|
// See the following:
|
|
// https://github.com/tinygo-org/tinygo/issues/351
|
|
// https://github.com/golang/go/commit/ad4a58e31501bce5de2aad90a620eaecdc1eecb8
|
|
|
|
//go:linkname indexByte strings.IndexByte
|
|
func indexByte(s string, c byte) int {
|
|
return bytealg.IndexByteString(s, c)
|
|
}
|
|
|
|
//go:linkname bytesEqual bytes.Equal
|
|
func bytesEqual(a, b []byte) bool {
|
|
return bytealg.Equal(a, b)
|
|
}
|