Compare commits

..

5 Commits

Author SHA1 Message Date
Ludovic Fernandez
24db786bb6 fix: exclude syslog for windows, nacl, and plan9. 2019-07-24 18:58:04 -07:00
Ludovic Fernandez
aa98e2c2a9 feat: support yaegi in go playground 2019-07-24 17:52:03 -07:00
Ludovic Fernandez
8ace2eb6e6 doc: improve documentation. 2019-07-24 11:44:04 -07:00
Cuong Manh Le
f2034819c2 fix: blank identifier cause panic (#255) 2019-07-24 11:20:04 -07:00
Brendan Le Glaunec
172d4a4657 Fix installation instructions (#250) 2019-07-24 09:11:07 -07:00
9 changed files with 24 additions and 20 deletions

View File

@@ -36,7 +36,7 @@ before_script:
script:
- make check
- go build -v ./...
- GO111MODULE=off go test -v ./...
- make tests
deploy:
- provider: script

View File

@@ -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

View File

@@ -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
View File

@@ -0,0 +1,9 @@
package main
func main() {
_ = 1
println(1)
}
// Output:
// 1

View File

@@ -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.

View File

@@ -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

View File

@@ -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

View File

@@ -1,4 +1,4 @@
// +build go1.11,!go1.12
// +build go1.11,!go1.12,!windows,!nacl,!plan9
package stdlib

View File

@@ -1,4 +1,4 @@
// +build go1.12,!go1.13
// +build go1.12,!go1.13,!windows,!nacl,!plan9
package stdlib