Update Interpreter.Use API
### Background #1102 changed how `Interpreter.Use` interprets export paths such that the last path component is stripped and used as the package name. This resulted in #1139 - attempting to Use an export with only one path component, such as `foo`, would result in the import path being `.`. ### Breaking API Change This PR changes the signature of `Interpreter.Use` from `Use(Exports)` to `Use(Exports) error`. ### Fix for #1139 With this PR, if Use is called with an incomplete export path, such as `foo`, Use will return an error.
This commit is contained in:
@@ -55,9 +55,15 @@ func runCheck(t *testing.T, p string) {
|
||||
}
|
||||
var stdout, stderr bytes.Buffer
|
||||
i := interp.New(interp.Options{GoPath: goPath, Stdout: &stdout, Stderr: &stderr})
|
||||
i.Use(interp.Symbols)
|
||||
i.Use(stdlib.Symbols)
|
||||
i.Use(unsafe.Symbols)
|
||||
if err := i.Use(interp.Symbols); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if err := i.Use(stdlib.Symbols); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if err := i.Use(unsafe.Symbols); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
_, err := i.EvalPath(p)
|
||||
if errWanted {
|
||||
|
||||
Reference in New Issue
Block a user