Skip to content
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

proposal: enbale convert []int32 to []MyInt32 #11958

Closed
chai2010 opened this issue Jul 31, 2015 · 2 comments
Closed

proposal: enbale convert []int32 to []MyInt32 #11958

chai2010 opened this issue Jul 31, 2015 · 2 comments

Comments

@chai2010
Copy link
Contributor

package main

import "fmt"

type MyInt32 int32
type MyInt32SliceA []int32
type MyInt32SliceB []MyInt32

func main() {
    var a int32
    var b = MyInt32(a)
    fmt.Println(b)

    var c []int32
    var d = MyInt32SliceA(c)
    fmt.Println(d)

    var e []int32
    var f = MyInt32SliceB(e) // cannot convert e (type []int32) to type MyInt32SliceB
    fmt.Println(f)
}

https://play.golang.org/p/BZ-prCewu0

@mattn
Copy link
Member

mattn commented Jul 31, 2015

probably, you know unsafe.

https://play.golang.org/p/GYcouM80-v

@robpike
Copy link
Contributor

robpike commented Aug 3, 2015

This would be a language change. The underlying types of MyInt32SliceA and ..B are different, so a conversion between them is not allowed.

@robpike robpike closed this as completed Aug 3, 2015
@golang golang locked and limited conversation to collaborators Aug 22, 2016
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

5 participants