Sql: converting argument $1 type: unsupported type [3]int64, a array

My function definition is

func (s *Stmt) CheckNamedValue(nv *driver.NamedValue) (err error) {
	switch d := nv.Value.(type) {
        case []int64:
                err = nil
	default:
		nv.Value, err = driver.DefaultParameterConverter.ConvertValue(nv.Value)
	}
	return err
}

This is function works fine if I pass []int64 but not [size]int64.
I am checking the type but why it is the above two are different?

Thanks,
Akhil

2 Likes

can any one help me on this?:disappointed::tired_face:

2 Likes

Go is static type so it is very strict with data type itself. []int64 is a slice (keeping it simple: "imagine it as a basket full of arrays to form “dynamic array”) while [size]int64 is an array. Since they are 2 different data types, Go will throw an error.

To fix this, you can easily convert any existing array into slice using the slice bound [:].

a := [size]int64{ ... }
x := a[:] // x is now []int64 type
2 Likes

All good there?

2 Likes

Thanks…It is working sorry for the late reply.

1 Like

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.