-
Notifications
You must be signed in to change notification settings - Fork 951
bytealg.CountString is not supported #424
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
A related function is implemented here in the runtime, which you can use as an example: Lines 184 to 194 in 40b193f
You could either implement your own version, or copy the one from the Go standard library: |
I wonder if I have understood correctly. package main
import (
"fmt"
"strings"
_ "unsafe"
)
func main() {
s := strings.Replace("abc", "a", "x", -1)
fmt.Println(s)
}
// paste from https://github.com/golang/go/blob/67f181bfd84dfd5942fe9a29d8a20c9ce5eb2fea/src/internal/bytealg/count_generic.go#L19
//go:linkname countString internal/bytealg.CountString
func countString(s string, c byte) int {
n := 0
for i := 0; i < len(s); i++ {
if s[i] == c {
n++
}
}
return n
} |
Sorry for the late reply. Outside of the runtime, |
OK I will wait the party. |
I think what @aykevl was saying @1l0 was that if you add that code to the correct place in the The Thanks! |
Exactly, what @deadprogram says. There is no reason to wait, just move |
Do you prefer that route (I mean patchwork-like)? I'm not hurrying so I can wait until fixing #285 that seems to fundamentally solve the problem. |
These seems some confusion. The bug mentioned has nothing to do with the #285 has nothing directly to do with your issue. I hope that clarifies. |
Signed-off-by: Ron Evans <[email protected]>
Signed-off-by: Ron Evans <[email protected]>
My own PR that implemented this based on your research @1l0 was merged into |
main.go:
run:
How can I fix this?
The text was updated successfully, but these errors were encountered: