mirror of https://github.com/golang/go.git
26 lines
326 B
Go
26 lines
326 B
Go
package source
|
|
|
|
import (
|
|
"go/parser"
|
|
"go/token"
|
|
"testing"
|
|
)
|
|
|
|
func TestTrimToImports(t *testing.T) {
|
|
const input = `package source
|
|
|
|
import (
|
|
m
|
|
"fmt"
|
|
)
|
|
|
|
func foo() {
|
|
fmt.Println("hi")
|
|
}
|
|
`
|
|
|
|
fs := token.NewFileSet()
|
|
f, _ := parser.ParseFile(fs, "foo.go", input, parser.ImportsOnly)
|
|
trimToImports(fs, f, []byte(input))
|
|
}
|