diff --git a/cmd/yaegi/yaegi.go b/cmd/yaegi/yaegi.go index 21fc1a61..ffd3f849 100644 --- a/cmd/yaegi/yaegi.go +++ b/cmd/yaegi/yaegi.go @@ -3,6 +3,7 @@ package main import ( "flag" "fmt" + "go/build" "io/ioutil" "log" "os" @@ -24,13 +25,15 @@ func main() { args := flag.Args() log.SetFlags(log.Lshortfile) - i := interp.New(interp.Options{}) + i := interp.New(interp.Options{GoPath: build.Default.GOPATH}) i.Use(stdlib.Symbols) i.Use(interp.Symbols) if len(args) > 0 { // Skip first os arg to set command line as expected by interpreted main os.Args = os.Args[1:] + flag.CommandLine = flag.NewFlagSet(os.Args[0], flag.ExitOnError) + b, err := ioutil.ReadFile(args[0]) if err != nil { log.Fatal("Could not read file: ", args[0]) diff --git a/stdlib/stdlib.go b/stdlib/stdlib.go index 1d68fded..6ec72461 100644 --- a/stdlib/stdlib.go +++ b/stdlib/stdlib.go @@ -5,6 +5,12 @@ import "reflect" // Symbols variable stores the map of stdlib symbols per package var Symbols = map[string]map[string]reflect.Value{} +func init() { + Symbols["github.com/containous/yaegi/stdlib"] = map[string]reflect.Value{ + "Symbols": reflect.ValueOf(Symbols), + } +} + // Provide access to go standard library (http://golang.org/pkg/) //go:generate ../cmd/goexports/goexports archive/tar archive/zip diff --git a/stdlib/syscall/syscall.go b/stdlib/syscall/syscall.go index a1f7e210..3d37063a 100644 --- a/stdlib/syscall/syscall.go +++ b/stdlib/syscall/syscall.go @@ -5,4 +5,10 @@ import "reflect" // Symbols stores the map of syscall package symbols var Symbols = map[string]map[string]reflect.Value{} +func init() { + Symbols["github.com/containous/yaegi/stdlib/syscall"] = map[string]reflect.Value{ + "Symbols": reflect.ValueOf(Symbols), + } +} + //go:generate ../../cmd/goexports/goexports syscall diff --git a/stdlib/unsafe/unsafe.go b/stdlib/unsafe/unsafe.go index 554eb3fc..b34d70f9 100644 --- a/stdlib/unsafe/unsafe.go +++ b/stdlib/unsafe/unsafe.go @@ -5,4 +5,10 @@ import "reflect" // Symbols stores the map of unsafe package symbols var Symbols = map[string]map[string]reflect.Value{} +func init() { + Symbols["github.com/containous/yaegi/stdlib/unsafe"] = map[string]reflect.Value{ + "Symbols": reflect.ValueOf(Symbols), + } +} + //go:generate ../../cmd/goexports/goexports unsafe