allow unused imports, update tests related to changes #20
Этот коммит содержится в:
родитель
bb0363c4bb
коммит
ca7ddd6275
2 изменённых файлов: 7 добавлений и 13 удалений
11
builder.go
11
builder.go
|
@ -220,7 +220,7 @@ func (b *builder) merge() ([]byte, error) {
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return false
|
return p == "_"
|
||||||
}
|
}
|
||||||
for _, spec := range b.imports {
|
for _, spec := range b.imports {
|
||||||
var name string
|
var name string
|
||||||
|
@ -397,11 +397,7 @@ func matchLen(x, y string) int {
|
||||||
}
|
}
|
||||||
|
|
||||||
func importPath(s *ast.ImportSpec) string {
|
func importPath(s *ast.ImportSpec) string {
|
||||||
t, err := strconv.Unquote(s.Path.Value)
|
return strings.Trim(s.Path.Value, `\"`)
|
||||||
if err == nil {
|
|
||||||
return t
|
|
||||||
}
|
|
||||||
return ""
|
|
||||||
}
|
}
|
||||||
|
|
||||||
var importPathToName = importPathToNameGoPath
|
var importPathToName = importPathToNameGoPath
|
||||||
|
@ -416,7 +412,6 @@ func importPathToNameBasic(importPath string) (packageName string) {
|
||||||
func importPathToNameGoPath(importPath string) (packageName string) {
|
func importPathToNameGoPath(importPath string) (packageName string) {
|
||||||
if buildPkg, err := build.Import(importPath, "", 0); err == nil {
|
if buildPkg, err := build.Import(importPath, "", 0); err == nil {
|
||||||
return buildPkg.Name
|
return buildPkg.Name
|
||||||
} else {
|
|
||||||
return importPathToNameBasic(importPath)
|
|
||||||
}
|
}
|
||||||
|
return importPathToNameBasic(importPath)
|
||||||
}
|
}
|
||||||
|
|
|
@ -102,7 +102,6 @@ func TestUsualSourceFileMerge(t *testing.T) {
|
||||||
expected := `package main
|
expected := `package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
|
||||||
a "fmt"
|
a "fmt"
|
||||||
b "fmt"
|
b "fmt"
|
||||||
"github.com/DATA-DOG/godog"
|
"github.com/DATA-DOG/godog"
|
||||||
|
@ -139,10 +138,8 @@ func TestShouldCallContextOnMerged(t *testing.T) {
|
||||||
t.Fatalf("unexpected error: %s", err)
|
t.Fatalf("unexpected error: %s", err)
|
||||||
}
|
}
|
||||||
expected := `package main
|
expected := `package main
|
||||||
import (
|
|
||||||
"fmt"
|
import "github.com/DATA-DOG/godog"
|
||||||
"github.com/DATA-DOG/godog"
|
|
||||||
)
|
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
godog.Run(func(suite *godog.Suite) {
|
godog.Run(func(suite *godog.Suite) {
|
||||||
|
@ -154,6 +151,8 @@ func myContext(s *godog.Suite) {
|
||||||
}`
|
}`
|
||||||
|
|
||||||
actual := string(data)
|
actual := string(data)
|
||||||
|
// log.Println("actual:", actual)
|
||||||
|
// log.Println("expected:", expected)
|
||||||
if b.cleanSpacing(expected) != b.cleanSpacing(actual) {
|
if b.cleanSpacing(expected) != b.cleanSpacing(actual) {
|
||||||
t.Fatalf("expected output does not match: %s", actual)
|
t.Fatalf("expected output does not match: %s", actual)
|
||||||
}
|
}
|
||||||
|
|
Загрузка…
Создание таблицы
Сослаться в новой задаче