gopherdata / gopherdata/gophernotes

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

オープン
#246 コメント 3 件 リアクション 1 件 担当者 1 名 @cosmos72 が担当を希望しています GitHub で見る
bug
主要言語
Go
スター
4k
フォーク
264
平均マージ
7日 21時間
マージ済み PR(30日)
1

説明

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
```
:)

コントリビューションガイド

このリポジトリのコントリビューションガイドは索引されていません

評価

この issue はまだ評価されていません。

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。