Compare commits
5 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
24db786bb6 | ||
|
|
aa98e2c2a9 | ||
|
|
8ace2eb6e6 | ||
|
|
f2034819c2 | ||
|
|
172d4a4657 |
@@ -36,7 +36,7 @@ before_script:
|
||||
script:
|
||||
- make check
|
||||
- go build -v ./...
|
||||
- GO111MODULE=off go test -v ./...
|
||||
- make tests
|
||||
|
||||
deploy:
|
||||
- provider: script
|
||||
|
||||
3
Makefile
3
Makefile
@@ -16,4 +16,7 @@ cmd/goexports/goexports: cmd/goexports/goexports.go
|
||||
generate: gen_all_syscall
|
||||
go generate
|
||||
|
||||
tests:
|
||||
GO111MODULE=off go test -v ./...
|
||||
|
||||
.PHONY: check gen_all_syscall gen_tests
|
||||
|
||||
@@ -16,6 +16,7 @@ It powers executable Go scripts and plugins, in embedded interpreters or interac
|
||||
* works everywhere Go works
|
||||
* All Go & runtime resources accessible from script (with control)
|
||||
* Security: `unsafe` and `syscall` packages not used or exported by default
|
||||
* Support Go 1.11 and Go 1.12 (the latest 2 major releases)
|
||||
|
||||
## Install
|
||||
|
||||
@@ -28,9 +29,12 @@ import "github.com/containous/yaegi/interp"
|
||||
### REPL
|
||||
|
||||
```bash
|
||||
go get -u github.com/containous/yaegi/cmd
|
||||
go get -u github.com/containous/yaegi/cmd/yaegi
|
||||
```
|
||||
|
||||
Note that you can use [rlwrap](https://github.com/hanslub42/rlwrap) (install with your favorite package manager),
|
||||
and alias the `yaegi` command in `alias yaegi='rlwrap yaegi'` in your `~/.bashrc`, to have history and command line edition.
|
||||
|
||||
## Usage
|
||||
|
||||
### As a command line interpreter
|
||||
|
||||
9
_test/assign8.go
Normal file
9
_test/assign8.go
Normal file
@@ -0,0 +1,9 @@
|
||||
package main
|
||||
|
||||
func main() {
|
||||
_ = 1
|
||||
println(1)
|
||||
}
|
||||
|
||||
// Output:
|
||||
// 1
|
||||
@@ -22,8 +22,8 @@ import (
|
||||
"text/template"
|
||||
)
|
||||
|
||||
const model = `// +build {{.CurrentGoVersion}},!{{.NextGoVersion}}
|
||||
|
||||
const model = `// +build {{.CurrentGoVersion}},!{{.NextGoVersion}}{{if eq .PkgName "log/syslog"}},!windows,!nacl,!plan9{{end}}
|
||||
|
||||
package {{.Dest}}
|
||||
|
||||
// Code generated by 'goexports {{.PkgName}}'. DO NOT EDIT.
|
||||
|
||||
@@ -343,7 +343,7 @@ func (interp *Interpreter) cfg(root *node) ([]*node, error) {
|
||||
dest, src := n.child[i], n.child[sbase+i]
|
||||
var sym *symbol
|
||||
var level int
|
||||
if n.kind == defineStmt {
|
||||
if n.kind == defineStmt || (n.kind == assignStmt && dest.ident == "_") {
|
||||
if src.typ != nil && src.typ.cat == nilT {
|
||||
err = src.cfgErrorf("use of untyped nil")
|
||||
break
|
||||
|
||||
@@ -123,7 +123,7 @@ type Options struct {
|
||||
// New returns a new interpreter
|
||||
func New(options Options) *Interpreter {
|
||||
i := Interpreter{
|
||||
opt: opt{goPath: getGoPath(options)},
|
||||
opt: opt{goPath: options.GoPath},
|
||||
fset: token.NewFileSet(),
|
||||
universe: initUniverse(),
|
||||
scopes: map[string]*scope{},
|
||||
@@ -143,18 +143,6 @@ func New(options Options) *Interpreter {
|
||||
return &i
|
||||
}
|
||||
|
||||
func getGoPath(options Options) string {
|
||||
if options.GoPath != "" {
|
||||
return options.GoPath
|
||||
}
|
||||
|
||||
goPath, err := os.Executable()
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return goPath
|
||||
}
|
||||
|
||||
func initUniverse() *scope {
|
||||
sc := &scope{global: true, sym: map[string]*symbol{
|
||||
// predefined Go types
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// +build go1.11,!go1.12
|
||||
// +build go1.11,!go1.12,!windows,!nacl,!plan9
|
||||
|
||||
package stdlib
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// +build go1.12,!go1.13
|
||||
// +build go1.12,!go1.13,!windows,!nacl,!plan9
|
||||
|
||||
package stdlib
|
||||
|
||||
|
||||
Reference in New Issue
Block a user