Skip to content

Commit e1d937e

Browse files
authored
Merge pull request #203 from cschleiden/analyzer-default-import
Use default import name from analyzer
2 parents 638245d + ae76d5d commit e1d937e

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

analyzer/analyzer.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,11 @@ func run(pass *analysis.Pass) (interface{}, error) {
6868
switch n := node.(type) {
6969
case *ast.ImportSpec:
7070
if n.Path.Value == `"github.com/cschleiden/go-workflows/workflow"` {
71-
workflowImportName = n.Name.Name
71+
if n.Name != nil {
72+
workflowImportName = n.Name.Name
73+
} else {
74+
workflowImportName = "workflow"
75+
}
7276
}
7377

7478
case *ast.FuncDecl:

analyzer/testdata/src/p/p.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import (
66
"fmt"
77
"time"
88

9-
workflow "github.com/cschleiden/go-workflows/workflow"
9+
"github.com/cschleiden/go-workflows/workflow"
1010

1111
"sync"
1212
)

0 commit comments

Comments
 (0)