I submitted CL to x/text, but no one seems to have any to review it at the
moment. I also checked the recent CL for x/text. again, no one is taking
care of it.
text has a several year old problem that has been resolved by the
corresponding CL, but has not been merged. I'd like to support if text
I am using generics here to work for other types as well, it 's not only for
converting int32[] slice to int64[], it is generic function to work for any
conversion like BytestoInt64/32/16/8, BytestoFloat32/64 etc.
It is failing for other conversion like BytestoInt64 , BytestoFloat64 etc on
big
There is typo mistake while entering, below is the code snippest:
package main
import (
"fmt"
"unsafe"
)
type slice struct {
ptr unsafe.Pointer
len int
cap int
}
func Slice[To, From any](data []From) []To {
var zf From
var zt To
var s = (*slice)(un
That code doesn't even compile in go 1.22 or go.1.21:
https://go.dev/play/p/mPCBUQizSVo
./prog.go:20:14: cannot convert unsafe.Pointer(s) (value of type
unsafe.Pointer) to type []To
What's the underlying requirement? In the test case it looks like you want
to take a slice of int32's, in whatever
Hello gopher's,
I have simple go program which convert slice of one type to slice of other
type using go generics for handling all the supported types.
Below is the code snippest for this:
package main
import "fmt"
import "unsafe"
type slice struct {
ptr unsafe.Pointer
len int