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