gopherdata / gopherdata/gophernotes

Error `cannot convert type <*main.b> to interface <error>` on valid Go code

Aberta
#246 3 comentários 1 reação 1 responsável Reivindicada por @cosmos72 Ver no GitHub
bug
Linguagem predominante
Go
Estrelas
4k
Forks
264
Merge médio
7d 21h
PRs com merge (30d)
1

Descrição

When attempting to run the following snippet of Go code in the latest version of gophernotes, `v0.7.4`, I get the following error:

```go
import "fmt"

type b struct {}
func (*b) Error() string { return "hi" }

func main() {
var e error
e = &b{}

fmt.Println(e)
}
```
```
repl.go:8:9: error compiling assignment: e = &b{}
repl.go:8:9: cannot convert type <*main.b> to interface : missing method Error
```

However, running essentially the same snippet with a `package main` declaration at the top yields the correc output.

```go
package main

import "fmt"

type b struct {}
func (*b) Error() string { return "hi" }

func main() {
var e error
e = &b{}

fmt.Println(e)
}
```
```
> go run main.go
hi
```
:)

Guia de contribuição

Nenhum guia de contribuição indexado para este repositório

Avaliação

Esta issue ainda não foi avaliada.

Receba novas issues na sua caixa de entrada

Um resumo curto de issues do GitHub para quem está começando.