x-motemen / gore Goto Github PK
View Code? Open in Web Editor NEWYet another Go REPL that works nicely. Featured with line editing, code completion, and more.
License: MIT License
Yet another Go REPL that works nicely. Featured with line editing, code completion, and more.
License: MIT License
Hey there Hiroshi, great job on gore ๐
I'm seeing a strange behaviour that I wanted to run by you. I just installed gore the 3 recommendations today and am seeing the following behaviour when I use println multiple times:
gore version 0.2.1 :help for help
gore> :import fmt
gore> fmt.Println("Hello, world")
Hello, world
13
nil
gore> fmt.Println("Hello, world")
Hello, world
Hello, world
13
nil
gore> fmt.Println("Hello, world")
Hello, world
Hello, world
Hello, world
13
nil
Things I didn't expect:
Am I doing something incorrectly?
Cheers
Fotis
Hello again,
The use of Ctrl+D throws me off quite a bit. In almost all REPLs, Ctrl+D is only used for ending the entire session or a more involved action.
Would you consider Ctrl+C for situations like this:
gore> import (
.....
..... ^C
..... ^C
..... ^C
.....
gore>
Thanks heaps ๐
Fotis
I've found an issue where after certain actions, the repl will just print out the "evaluated but not used" error after every input line.
gore version 0.2.6 :help for help
gore> type Foo interface{}
gore> fn := func() []Foo {return []Foo{}}
(func() []main.Foo)0x2180
gore> len(fn())
(int)0
gore> 1 + 2
# command-line-arguments
/var/folders/vt/nnyw4nc12dx26w2bkmc4z7380000gp/T/037577958/gore_session.go:10: len(fn()) evaluated but not used
error: exit status 2
exit status 2
gore>
Maybe moving main.go to github.com/motemen/gore/cmd/gore
It would be great to be able to use Alt-B and Alt-F to skip backward and forward by a word.
Is there anyway to undo my input or if I import the wrong package how to cancel it ?
gore> h\ello<enter>
..... <enter>
..... <ctrl-d>
gore> hello\t<enter>
..... <enter>
..... <ctrl-d>
gore> he\\llo<enter>
..... <enter>
.....
Only a couple escape sequences are valid: https://golang.org/ref/spec#Rune_literals
hello,
nice work with gore. i would like to be able to copy text from vim directly into gore. but when i copy a text like this
pam := make([][]int, h)
from vim into the gore command line, ends like:
gore> __gore_p(pam := make([][]int, h)
i can only image of the tab being scape or something..
can you help me here?
thanks
I'm trying to import a package inside a vendor
subdirectory in my project. I get the following when importing directly:
gore> :import github.com/aws/aws-sdk-go
error: import: can't find import: vendor/github.com/aws/aws-sdk-go
I tried working around it by treating my vendor directory as a temporary GOPATH, and it worked:
ln -s $PWD/vendor /tmp/go/src
GOPATH=/tmp/go go install github.com/aws/aws-sdk-go
GOPATH=/tmp/go gore
gore> :import github.com/aws/aws-sdk-go
(no error)
This isn't really a workable solution though. Is there a way for gore to find these packages? I know they have to be go install
'ed first - maybe that's part of the issue?
Starting a routine that panics immediately continues with no indication.
$ gore
gore version 0.2.5 :help for help
gore> go func(){panic("some panic")}()
gore>
Or indeed invoking the panic directly.
$ gore
gore version 0.2.5 :help for help
gore> go panic("some panic")
gore>
The playground (or a normal go program) will halt execution in this event example.
Exiting would clearly not be an ideal solution for a REPL, but some kind of notification to the user that a panic has occurred would be beneficial.
I'm kind of new to Go, was attempting to install gore and ran into this:
$ mkdir /tmp/gore
$ cd /tmp/gore
$ ls
$ export GOPATH=$(pwd -P)
$ go get github.com/motemen/gore
# github.com/motemen/gore
/private/tmp/gore/src/github.com/motemen/gore/commands.go:246: not enough arguments in call to mainScope.LookupParent
$ go env
GOARCH="amd64"
GOBIN=""
GOCHAR="6"
GOEXE=""
GOHOSTARCH="amd64"
GOHOSTOS="darwin"
GOOS="darwin"
GOPATH="/private/tmp/gore"
GORACE=""
GOROOT="/opt/twitter/Cellar/go/1.4.2/libexec"
GOTOOLDIR="/opt/twitter/Cellar/go/1.4.2/libexec/pkg/tool/darwin_amd64"
CC="clang"
GOGCCFLAGS="-fPIC -m64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fno-common"
CXX="clang++"
CGO_ENABLED="1"
$ go version
go version go1.4.2 darwin/amd64
I've tried going back roughly 10 versions of master, and each one fails with the same message. Is this a known issue? Am I missing something obvious? Is there any other information I can provide which would help?
Just like bash's shortcut to remove last typed word (alt+backspace)
I had to look up the readme at github to see how to exit. These two options exist (if you agree it is an issue):
:help
is displayedgore version 0.2.2 :help for help Ctrl-D to exit
Does gore have a programmatic API? I recently added Go to repl.it but it's not really running as a REPL. You can just run the code http://repl.it/languages/Go
With gore, it would be epic. Are there instructions on how to use it as a library?
Took me a while to figure out I needed to call go get local/project/package
vs. just importing the local package file path. Can you add to the documentation how to install local packages, puhlease? I'm happy to make a change myself, just let me know.
$ go get github.com/motemen/gore
package golang.org/x/tools/go/gcimporter: cannot find package "golang.org/x/tools/go/gcimporter" in any of:
/usr/local/Cellar/go/1.8.2/libexec/src/golang.org/x/tools/go/gcimporter (from $GOROOT)
/Users/Will/Developer/go/src/golang.org/x/tools/go/gcimporter (from $GOPATH)
$ go version
go version go1.8.2 darwin/amd64
$ go env
GOARCH="amd64"
GOBIN=""
GOEXE=""
GOHOSTARCH="amd64"
GOHOSTOS="darwin"
GOOS="darwin"
GOPATH="/Users/Will/Developer/go"
GORACE=""
GOROOT="/usr/local/Cellar/go/1.8.2/libexec"
GOTOOLDIR="/usr/local/Cellar/go/1.8.2/libexec/pkg/tool/darwin_amd64"
GCCGO="gccgo"
CC="clang"
GOGCCFLAGS="-fPIC -m64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=/var/folders/bx/qk0phsxd265fqj512dnnpg080000gn/T/go-build961897595=/tmp/go-build -gno-record-gcc-switches -fno-common"
CXX="clang++"
CGO_ENABLED="1"
PKG_CONFIG="pkg-config"
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
$ gore -autoimport
gore version 0.2.5 :help for help
gore> time.Now().Add(time.Hour * 24).UnixNano() / 1e6
1446750220830
gore> time.Now().Add(time.Hour * 24).UnixNano() / 1e6
# command-line-arguments
/var/folders/s3/2h4dlfnj4qscnpjj7dy00mmr0000gn/T/709813128/gore_session.go:15: time.Now().Add(time.Hour * 24).UnixNano() / 1e+06 evaluated but not used
error: exit status 2
exit status 2
Does not work for me:
go get -u github.com/motemen/gore
causes this
cannot find package "golang.org/x/tools/go/gcimporter" in any of: ...
It seems like both the time.Now()
and .UTC()
values get printed:
$ gore -autoimport
gore> time.Now().UTC()
time.Time{sec:63576820296, nsec:236228056, loc:(*time.Location)(0x21b860)}2015-09-02 19:51:36 UTC
Also, strangely, the formats are different.
Really loving gore so far, but found an odd bug.
If I run this command first: go get github.com/leanovate/gopter
then try the following gore commands:
:import github.com/leanovate/gopter
(this one works).
:import github.com/leanovate/gopter/gen
This one fails with error: import: can't find import: github.com/leanovate/gopter/prop
Double checking that it exists:
$ grep 'package prop' $GOPATH/src/github.com/leanovate/gopter/prop/*
/Users/ash/code/go/src/github.com/leanovate/gopter/prop/check_condition_func.go:package prop
/Users/ash/code/go/src/github.com/leanovate/gopter/prop/check_condition_func_test.go:package prop
/Users/ash/code/go/src/github.com/leanovate/gopter/prop/convert_result.go:package prop
Have I done something stupid? Is this a bug in gopter? I got the package name from the Invalidconcat example here: https://godoc.org/github.com/leanovate/gopter/prop#example-package--Invalidconcat
gore uses the deprecated types package from x/tools, and as of this commit types has been removed from x/tools. Most of the functionality is in the std lib as go/types, but some of it has been split out into go/importer. I tried to port over the code myself, but I don't understand it well enough and I don't have the time right now to dive into it.
Also x/tools/gcimporter has been deleted as well, maybe this can be swapped out with x/tools/gcimporter15? It seemed to compile fine when I made that change, but I don't know if the semantics changed.
This issue goes hand-in-hand with this pull-request for go-quickfix
Tejass-MacBook-Pro:backend tejas$ gore
gore version 0.2.5 :help for help
gore> :import time
gore> time
/var/folders/mr/qvzhzl8j0ldc1fj8wvm7fsy40000gn/T/122898852/gore_session.go:13: undefined: time
error: exit status 2
exit status 2
gore> :import "time"
gore> time
/var/folders/mr/qvzhzl8j0ldc1fj8wvm7fsy40000gn/T/122898852/gore_session.go:13: undefined: time
error: exit status 2
exit status 2
gore version 0.0.0 :help for help
gore> (4 & ( 1 << 1)) != 0
(bool)false
gore> (4 & ( 1 << 2)) != 0
# command-line-arguments
/var/folders/f2/x6w4b70x09x0kq7hy1cb_8gr0000gp/T/515099668/gore_session.go:13: 0 != 0 evaluated but not used
error: exit status 2
exit status 2
Typing a similar expression twice produces an evaluated but not used
error.
Can't execute some expressions like:
import "fmt"
Can't complete on some keywords, like:
import
func
End a line with a left parenthesis, enter a new line, then enter tab to indent:
$ gore
gore version 0.2.2 :help for help
gore> func(x int){}(
..... __gore_p(
Instead of a tab, __gore_p(
is inserted where the cursor was, and the cursor is moved after the insertion.
Looks related to #20.
$ go version
go version go1.5 darwin/amd64
$ gore
gore version 0.2.5 :help for help
gore> :import fmt
gore> fmt.Println("Yoo")
Yoo
4
<nil>
gore> n := 1
Yoo // <--- why is this printed?
1
I cannot see any license in the repository.
Can you add one or mention what license it is released?
Thanks.
Would be great to have a clean command, that would allow not to restart gore just to cleanup the current code in the main function.
Hello!
I've noticed a problem with pretty printer - some things causes failure of k0kubun/pp:
โ gore gore version 0.2.5 :help for help gore> :import "fmt" gore> :import "github.com/moovweb/gokogiri/xml" gore> doc := xml.CreateEmptyDocument([]byte("utf-8"), []byte("utf-8")) ... gore> root := doc.Root() unexpected fault address 0xffffffffffffffff fatal error: fault [signal 0xb code=0x1 addr=0xffffffffffffffff pc=0x40ada08]
Here is the details: https://gist.github.com/mulev/01eae0a8e0a7cd6d917f
Hi, i think the ability to import multiple packages on a single line would be a great addition.. Something like :import time,fmt,encoding/json
. The separator here is a comma(,
) but a space can be used too.
Thanks
gore> :import "fmt"
gore> fmt.Println("ha!")
ha!
(int)4
(interface {})<nil>
gore> fmt.Println("ha!")
ha!
ha!
(int)4
(interface {})<nil>
gore> fmt.Println("ha!")
ha!
ha!
ha!
(int)4
(interface {})<nil>
gore> fmt.Println("ha!");
ha!
ha!
ha!
ha!
gore>
gore>
gore>
See the above short session, and note that the calls to fmt.Println("ha!")
seem to stack and repeat each time fmt.Println
is used, is this intended?
Also note that omitting the semicolon results in
(int)4
(interface {})<nil>
being printed after the accumulated output from fmt.Println
.
go version go1.6.1 gccgo (GCC) 6.1.1 20160707 linux/amd64
GOARCH="amd64"
GOBIN=""
GOEXE=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOOS="linux"
GOPATH="/home/ashnur/projects/go"
GORACE=""
GOROOT="/usr"
GOTOOLDIR="/usr/lib/gcc/x86_64-pc-linux-gnu/6.1.1"
GO15VENDOREXPERIMENT="1"
CC="/usr/bin/gcc"
GOGCCFLAGS="-fPIC -m64 -pthread -fmessage-length=0"
CXX="/usr/bin/g++"
CGO_ENABLED="1"
I did what's in the README. Then I run gore and this happens:
~ : gore
panic: gccgo importer for custom import path lookup not yet implemented
goroutine 16 [running]:
runtime_dopanic
/build/gcc/src/gcc/libgo/runtime/panic.c:131
__go_panic
/build/gcc/src/gcc/libgo/runtime/go-panic.c:111
go_importer.For
/build/gcc/src/gcc/libgo/go/go/importer/importer.go:35
go_importer.Default
/build/gcc/src/gcc/libgo/go/go/importer/importer.go:55
main.NewSession
/home/ashnur/projects/go/src/github.com/motemen/gore/main.go:215
main.main
/home/ashnur/projects/go/src/github.com/motemen/gore/main.go:60
runtime_main
/build/gcc/src/gcc/libgo/runtime/proc.c:626
goroutine 17 [syscall]:
goroutine in C code; stack unavailable
created by runtime_main
/build/gcc/src/gcc/libgo/runtime/proc.c:598
goroutine 18 [finalizer wait]:
runtime_mcall
/build/gcc/src/gcc/libgo/runtime/proc.c:295
runfinq
/build/gcc/src/gcc/libgo/runtime/mgc0.c:2512
kickoff
/build/gcc/src/gcc/libgo/runtime/proc.c:235
created by runtime_createfing
/build/gcc/src/gcc/libgo/runtime/mgc0.c:2577
goroutine 19 [syscall]:
goroutine in C code; stack unavailable
created by os_signal..import
/build/gcc/src/gcc/libgo/go/os/signal/signal_unix.go:26
goroutine 20 [runnable]:
runtime_mcall
/build/gcc/src/gcc/libgo/runtime/proc.c:295
bgsweep
/build/gcc/src/gcc/libgo/runtime/mgc0.c:1833
kickoff
/build/gcc/src/gcc/libgo/runtime/proc.c:235
created by mgc
/build/gcc/src/gcc/libgo/runtime/mgc0.c:2215
First of all, thanks a lot for this awesome stuff. Absolutely love it.
I am sorry as this is a pretty basic question. I don't know how I can exit from REPL.
It seems Ctrl+C
, exit
and quit
don't work and I can't find anywhere in the code, :help
or in README about it.
Here's what happened what I tried quit
gore version 0.0.0 :help for help
gore> quit
# command-line-arguments
/var/folders/21/6n2vjp8d5q5czng49nh3h4240000gn/T/627674172/gore_session.go:12: undefined: quit
error: exit status 2
exit status 2
gore>
Currently I can't define more than one const in a declaration list
gore version 0.2.4 :help for help
gore> const (
..... a = iota
..... b = iota
..... c = iota
..... )
gore> fmt.Println(a)
0
2
<nil>
gore> fmt.Println(b)
# command-line-arguments
/var/folders/n7/lmdrbrks7zqd2ns7rwj8rjf80000gn/T/131512700/gore_session.go:13: undefined: b
error: exit status 2
exit status 2
gore> fmt.Println(c)
# command-line-arguments
/var/folders/n7/lmdrbrks7zqd2ns7rwj8rjf80000gn/T/131512700/gore_session.go:13: undefined: c
error: exit status 2
exit status 2
gore>
Note that I entered a }
after if i == 5 { break }
but for some reason that's not shown in the output.
$ gore -autoimport
gore version 0.2.5 :help for help
gore> for i := 0; i < 50000; i++ {
..... if err := exec.Command("./myscript", fmt.Sprintf("name+%[email protected]", i), fmt.Sprintf("password-%v, i), fmt.Sprintf("first-%v", i), fmt.Sprintf("last-%v", i)).Run(); err != nil {
..... fmt.Println("Error: %v: %v", i, err)
..... }
..... if i == 5 { break }
panic: runtime error: makeslice: len out of range
goroutine 1 [running]:
strings.Repeat(0x35e968, 0x4, 0xffffffffffffffff, 0x0, 0x0)
/usr/local/Cellar/go/1.5.1/libexec/src/strings/strings.go:464 +0x5f
main.(*contLiner).promptString(0x8205f1880, 0x0, 0x0)
/Users/Me/src/github.com/motemen/gore/liner.go:33 +0x54
main.(*contLiner).Reindent(0x8205f1880)
/Users/Me/src/github.com/motemen/gore/liner.go:81 +0xfc
main.main()
/Users/Me/src/github.com/motemen/gore/main.go:119 +0xb16
goroutine 5 [syscall]:
os/signal.loop()
/usr/local/Cellar/go/1.5.1/libexec/src/os/signal/signal_unix.go:22 +0x18
created by os/signal.init.1
/usr/local/Cellar/go/1.5.1/libexec/src/os/signal/signal_unix.go:28 +0x37
goroutine 6 [select, locked to thread]:
runtime.gopark(0x427130, 0x82061c728, 0x362798, 0x6, 0x3f118, 0x2)
/usr/local/Cellar/go/1.5.1/libexec/src/runtime/proc.go:185 +0x163
runtime.selectgoImpl(0x82061c728, 0x0, 0x18)
/usr/local/Cellar/go/1.5.1/libexec/src/runtime/select.go:392 +0xa64
runtime.selectgo(0x82061c728)
/usr/local/Cellar/go/1.5.1/libexec/src/runtime/select.go:212 +0x12
runtime.ensureSigM.func1()
/usr/local/Cellar/go/1.5.1/libexec/src/runtime/signal1_unix.go:227 +0x323
runtime.goexit()
/usr/local/Cellar/go/1.5.1/libexec/src/runtime/asm_amd64.s:1696 +0x1
Just a quick question, what tool did you use to record the terminal interaction? Looks awesome.
This is all on a Mac, OS 10.10.3.
$ go version
go version go1.4.2 darwin/386
$ go get github.com/motemen/gore
// reload terminal
$ gore
-bash: gore: command not found
Am I missing something?
How about using the Plugin API for a more lightweight RPC mechanism.
Example: https://github.com/dragonfax/go_repl_plugin_example
I'm sure I'm missing something very obvious but I'm not sure how to write a multi-line function in gore:
[dtenenba@C02S72TRFVH8 ~]$ gore
gore version 0.2.6 :help for help
gore> func Foo() string {
..... return "foo"
..... }
.....
How do I get out of .....
land and back to the gore>
prompt so I can call my function?
Same thing happens if I write the function as a one-liner:
[dtenenba@C02S72TRFVH8 ~]$ gore
gore version 0.2.6 :help for help
gore> func Foo() string { return "foo" }
.....
When asign time.Now()
to a variable, that variable is not fixed and changes every time you print it
t1 := time.Now()
t2 := time.Now()
t1 // one value
t1 // would print another value
t2.Sub(t1)
t2.Sub(t1) // different from previous evaluation
my gore version is 0.2.5 and go version is 1.5.2
Same issues with vektra/mockery#6
commands.go:17:2: cannot find package "golang.org/x/tools/go/ast/astutil" in any of:
/usr/lib/go/src/golang.org/x/tools/go/ast/astutil (from $GOROOT)
/home/asd/Dropbox/go/src/golang.org/x/tools/go/ast/astutil (from $GOPATH)
$ gore
gore version 0.2.2 :help for help
gore> type X struct {}
gore> func (X) Y() {}
.....
.....
.....
Not sure why the side effect of fmt.Printf should appear when I declare a variable.
gore> :import "fmt"
gore> fmt.Printf("foo\n")
foo
4
nil
gore> var i int
foo
gore>
$ gore
gore version 0.2.6 :help for help
gore> :import foo.com/web/bar/client
gore> :import github.com/cactus/go-statsd-client/statsd
gore> stats, err := statsd.NewNoopClient()
# command-line-arguments
/var/folders/w5/78q6nz451l104zzfdljf13jxhmx2wt/T/410385164/gore_session.go:6: imported and not used: "foo.com/web/bar/client" as bar
error: exit status 2
exit status 2
gore>
Reference: http://play.golang.org/p/_lYNw9SXN5
When trying this example, line by line, gore yields a different result than my test script locally and on the playground.
$ gore
gore version 0.2.2 :help for help
gore> a := []string{"hello", "world"}
[]string{"hello", "world"}
gore> b := []string{"goodbye", "world"}
[]string{"goodbye", "world"}
gore> copy(a, b)
2
gore> a
[]string{"hello", "world"}
gore> fmt.Println(a)
[hello world]
14
<nil>
gore>
Hi I've tried go-getting gore (go get github.com/motemen/gore
) and it doesn't build:
Dev/go/src/github.com/motemen/gore/commands.go:251: too many arguments in call to mainScope.LookupParent
Cheers!
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.