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

fmt wrongly detects type of list item in []interface{} as another []interface{} instead of interface{} #14695

Closed
ProhtMeyhet opened this issue Mar 7, 2016 · 4 comments

Comments

@ProhtMeyhet
Copy link

  1. What version of Go are you using (go version)?
    go1.6
  2. What operating system and processor architecture are you using (go env)?
    amd64 / linux
  3. What did you do?
    https://play.golang.org/p/aPx9TXrNaQ
  4. What did you expect to see?
    []interface {}, interface {} = test
  5. What did you see instead?
    []interface {}, []interface {} = [test]

as you can see it's a bit tricky to hit as - what i can see - there's a need to totally loose the original type information via a struct.

the compiler however is correct in this case, as if you uncomment lines 27 - 29 you get a compile time error:

prog.go:27: cannot range over ss (type interface {})

@bradfitz
Copy link
Contributor

bradfitz commented Mar 7, 2016

Let's move this to a forum. See https://golang.org/wiki/Questions

The type of atype ...interface{} is indeed []interface{}.

@bradfitz bradfitz closed this as completed Mar 7, 2016
@ProhtMeyhet
Copy link
Author

but why is there a difference between the compiler and fmt?

@bradfitz
Copy link
Contributor

bradfitz commented Mar 7, 2016

There is no difference. The compiler's error message is correct.

Let's move this to a forum and discuss there.

@ProhtMeyhet
Copy link
Author

but i said it's not a compiler bug, but a bug in fmt.

https://forum.golangbridge.org/t/difference-between-fmt-and-the-compiler-regarding-interface/2116

@golang golang locked and limited conversation to collaborators Mar 13, 2017
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

3 participants