From f46758caedb0bbc8a411be3b865ced1b1ab9c614 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Benjamin=20B=C3=B6hmke?= Date: Wed, 26 Feb 2020 21:08:59 +0100 Subject: [PATCH] xgotext: fixed parsing of error types --- cli/xgotext/fixtures/main.go | 4 ++++ cli/xgotext/parser/golang.go | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/cli/xgotext/fixtures/main.go b/cli/xgotext/fixtures/main.go index 19b0b0a..29944d1 100644 --- a/cli/xgotext/fixtures/main.go +++ b/cli/xgotext/fixtures/main.go @@ -1,6 +1,7 @@ package main import ( + "errors" "fmt" "github.com/leonelquinteros/gotext" @@ -78,6 +79,9 @@ func main() { // redefine alias with fake struct alias := Fake2{} alias.Get("3") + + err := errors.New("test") + fmt.Print(err.Error()) } // dummy function diff --git a/cli/xgotext/parser/golang.go b/cli/xgotext/parser/golang.go index 62fbdd9..bb63c72 100644 --- a/cli/xgotext/parser/golang.go +++ b/cli/xgotext/parser/golang.go @@ -165,7 +165,7 @@ func (g *GoFile) checkType(rawType types.Type) bool { return g.checkType(t.Elem()) case *types.Named: - if t.Obj().Pkg().Path() != "github.com/leonelquinteros/gotext" { + if t.Obj().Pkg() == nil || t.Obj().Pkg().Path() != "github.com/leonelquinteros/gotext" { return false } default: