I am trying to port a hash function from C to Go using unsafe.Pointer
. I need to get the pointer to the first character of the key string.
I tried &(hello[0])
and &hello[0]
and failed.
I am trying to port a hash function from C to Go using unsafe.Pointer
. I need to get the pointer to the first character of the key string.
I tried &(hello[0])
and &hello[0]
and failed.
In golang string it's a massive of bytes, need convert string to rune
package main
import (
"fmt"
)
func test(r *rune) {
*r = rune('L')
}
func main() {
s := []rune("Hello")
fmt.Println(string(s))
fmt.Println(&s[0])
test(&s[0])
fmt.Println(string(s))
}