mirror of
https://github.com/golang/go
synced 2024-11-18 22:04:43 -07:00
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))
|
||
|
}
|