Yet another Go REPL that works nicely. Featured with line editing, code completion, and more.

gore CI Status

Yet another Go REPL that works nicely. Featured with line editing, code completion, and more.

Screencast

(Screencast taken with cho45/KeyCast)

Usage

gore

After a prompt is shown, enter any Go expressions/statements/functions or commands described below.

To quit the session, type Ctrl-D or use :q command.

Features

  • Line editing with history
  • Multi-line input
  • Package importing with completion
  • Evaluates any expressions, statements and function declarations
  • No "evaluated but not used" errors
  • Code completion (requires gocode)
  • Showing documents
  • Auto-importing (gore -autoimport)

REPL Commands

Some functionalities are provided as commands in the REPL:

:import <package path>  Import package
:type <expr>            Print the type of expression
:print                  Show current source
:write [<filename>]     Write out current source to file
:clear                  Clear the codes
:doc <expr or pkg>      Show document
:help                   List commands
:quit                   Quit the session

Supported Versions

Only the latest major version.

Installation

The gore command requires Go tool-chains on runtime, so standalone binary is not distributed.

go get github.com/motemen/gore/cmd/gore

Make sure $GOPATH/bin is in your $PATH.

Also recommended:

go get github.com/mdempsky/gocode   # for code completion

Or you can use Docker:

git clone https://github.com/motemen/gore.git
cd gore
docker build -t gore .
docker run -it --rm gore

FAQ/Caveats

  • gore runs code using go run for each input. All the inputted lines are evaluated again and again so you can't bind the evaluated time by time.Now(), for example. If you don't like this behavior, you may want to use yaegi.
  • gore support Go modules. You can load local modules when you start gore at the project directory. You don't need to go get to check the usage of a remote repository, :import github.com/... will automatically download that module. Also, you don't need to go get the pretty print module anymore. If you want to load a local code from $GOPATH, you need to create the modules file (go mod init ...) and then start gore at the project directory.

License

The MIT License.

Author

motemen <[email protected]>

Owner
Comments
  • Cannot run `gore`

    Cannot run `gore`

    $ gore
    gore: could not load 'fmt' package: err: exit status 1: stderr: build flag -mod=mod only valid when using modules
    
    

    I have GOPATH and GOROOT set up correctly and it is reflected in go env

  • gore can't import vendored packages

    gore can't import vendored packages

    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?

  • astutil gone, cannot build

    astutil gone, cannot build

    Same issues with https://github.com/vektra/mockery/issues/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)
    
  • Failure with 'malformed module path

    Failure with 'malformed module path "XXX": missing dot in first path element'

    I have a config module available on GOPATH. I verify this by running the following program:

    package main
    
    import (
        "config"
        "fmt"
    )
    
    func main() {
        _ = config.NewConfig()
        fmt.Printf("OK\n")
    }
    
    

    When run, this prints as expected:

    $ go run main.go
    OK
    

    However, with gore, I get an error:

    $ gore
    gore version 0.5.0  :help for help
    gore> :import config
    gore> :import fmt
    gore> _ = config.NewConfig()
    cannot load config: malformed module path "config": missing dot in first path element
    gore> fmt.Printf("OK\n")
    cannot load config: malformed module path "config": missing dot in first path element
    gore> :print
    package main
    
    import (
        "github.com/k0kubun/pp"
        "fmt"
        "config"
    )
    
    func __gore_p(xs ...interface{}) {
        for _, x := range xs {
            pp.Println(x)
        }
    }
    func main() { _ = config.NewConfig(); _, _ = fmt.Printf("OK\n") }
    
    gore> 
    

    Am I doing something wrong? I just updated gore after running into #172 and I've tried updating gore both with GO111MODULE=on and without.

  • gore failed on MacOS 10.15.6 with go 1.15.7

    gore failed on MacOS 10.15.6 with go 1.15.7

    ~ > go version go version go1.15.7 darwin/amd64

    ~ > gore gore: could not load 'fmt' package: err: exit status 1: stderr: build flag -mod=mod only valid when using modules

  • Import packages from external golang source code

    Import packages from external golang source code

    I want to import package from external golang source. This pull request enables that by -include option.

    $ cd $GOPATH/src/github.com/motemen/gore
    $ gore -include main.go
    gore version 0.0.0  :help for help
    gore> homedir.Dir()
    "/Users/tcnksm"
    nil
    gore>
    

    I'm not sure implicit vs. explicit import (cf. https://github.com/motemen/gore/pull/2) But for me, session should be what I expected like ruby's irb.

    This is just proposal.

  • writing a function in gore?

    writing a function in gore?

    I'm sure I'm missing something very obvious but I'm not sure how to write a multi-line function in gore:

    [[email protected] ~]$ 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:

    [[email protected] ~]$ gore
    gore version 0.2.6  :help for help
    gore> func Foo() string { return "foo" }
    .....
    
  • Import fails to find pacakge that exists

    Import fails to find pacakge that exists

    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

  • String length error

    String length error

    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
    
  • backslashes break gore's scanner

    backslashes break gore's scanner

    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

  • Error occurs: `Unexpected package creation during export data loading`

    Error occurs: `Unexpected package creation during export data loading`

    $ gore
    gore version 0.5.0  :help for help
    gore> :import config
    gore> :print
    package main
    
    import (
        "github.com/k0kubun/pp"
        "config"
    )
    
    func __gore_p(xs ...interface{}) {
        for _, x := range xs {
            pp.Println(x)
        }
    }
    func main() {}
    
    gore> cfg := config.NewConfig()
    2020/01/17 18:53:02 Unexpected package creation during export data loading
    

    How can I progress?

  • Printing the values of variables should be optional

    Printing the values of variables should be optional

    If I do at the gore> prompt

    some_var, err := some_func()
    

    the values of some_var and err are always printed. Can this be made optional? If I want to type more than one command when exploring some library, for example, I don't necessarily want to clutter the display with all elements of returned structures. Of course, typing the name of a variable should display the value, as it does currently - it just shouldn't perhaps print automatically on assignments. This is related to #139, I guess.

  • importing database driver

    importing database driver

    gore> :import github.com/lib/pq no errors connect to a postgres database gore> (*errors.errorString)sql: unknown driver "postgres" (forgotten import?)

    How do I import github.com/lib/pq properly? Thank you!

A program to build, run, and restart a Go program on code change

devrun A program to build, run, and restart a Go program on code change. It also supports watching all your Go imports too. So if you change the code

Apr 4, 2022
Will autobuild and kill/relaunch the target when you update the code.

Use like rerun github.com/skelterjohn/go.uik/uiktest Usage: rerun [--test] [--build] [--race] [--no-run] <import path> [arg]* For any go executable in

Jun 16, 2022
Generate code for any language, with any language.

gocog - generate code for any language, with any language gocog v1.0 build 20130206 Binaries for popular OSes are available on the Downloads page of t

Feb 11, 2021
Go package for syntax highlighting of code

syntaxhighlight Package syntaxhighlight provides syntax highlighting for code. It currently uses a language-independent lexer and performs decently on

Jun 17, 2022
🔥 Continuous profiling platform — debug performance issues in your code!
🔥  Continuous profiling platform — debug performance issues in your code!

Pyroscope is an open source continuous profiling platform.

Jun 25, 2022
A tool that helps you write code in your favorite IDE: your word processor!
A tool that helps you write code in your favorite IDE: your word processor!

WordIDE Have you ever wondered: How would it feel like to write code in a word processor? Me neither. But after months minutes of planning, I present

May 20, 2022
Simple tool that updates Visual Studio Code workspace(s) to include Go modules in gopath/src, then launches VSCode if only one modified.

Simple tool that updates Visual Studio Code workspace(s) to include Go modules in gopath/src, then launches VSCode if only one modified.

Jan 27, 2022
Go structure annotations that supports encoding and decoding; similar to C-style bitfields. Supports bitfield packing, self-describing layout parameters, and alignment.
Go structure annotations that supports encoding and decoding; similar to C-style bitfields. Supports bitfield packing, self-describing layout parameters, and alignment.

STRUCTure EXtensions structex provides annotation rules that extend Go structures for implementation of encoding and decoding of byte backed data fram

Apr 19, 2022
ide-gen is a tool for development workspace prepare automation by automatic VCS repositories discovery and clone and project generation for supported IDEs.

ide-gen is a tool for development workspace prepare automation by automatic VCS repositories discovery and clone and project generation for supported IDEs.

May 8, 2022
Download, build, cache and run a Go app easily.

demand -- An easy way to install apps demand will download, build, cache and run a Go app. You can use it as an interpreter. Create a file bytes2human

Sep 10, 2017
cmd tool for automatic storage and comparison of benchmarks results

prettybenchcmp prettybenchcmp is cmd tool for storage and comparison of benchmarks results. There is a standard tool benchcmp, but I don't think that

Apr 6, 2021
golang feature toggle library - a library to help make golang feature toggling clean and easy

toggle supports env_variable backed toggling. It can also be updated via a pubsub interface (tested w/ redis) 2 engines for toggle backing are include

Mar 29, 2022
Aegis is a library that allows you detect if your software is being debugged or not on Linux, FreeBSD, NetBSD, OpenBSD and Windows
Aegis is a library that allows you detect if your software is being debugged or not on Linux, FreeBSD, NetBSD, OpenBSD and Windows

Aegis is a library that allows you detect if your software is being debugged or not on Linux, FreeBSD, NetBSD, OpenBSD and Windows. You can use it natively from C or use the Go bind.

Apr 27, 2022
Docker For Go Application Packaging And Pushing To Docker Hub

DOCKER-FOR-GO-APPLICATION-PACKAGING-AND-PUSHING-TO-DOCKER-HUB ##DOCKER COMMANDS: (Don't forget to navigate to the directory that contains the app and

Jan 22, 2022
Template project to get started with a simple API skeleton in Go and Docker

A template project to create a Docker image for a Go application. The example application exposes an HTTP endpoint through a REST API packaged as a static binary.

Apr 4, 2022
A simple application to show how to use dd-trace-go's tracer and profiler.

dd-trace-go-demo A simple application to show how to use dd-trace-go's tracer and profiler. Usage To run this demo application, simply clone this repo

Mar 2, 2022
Yet another Go REPL that works nicely. Featured with line editing, code completion, and more.
  Yet another Go REPL that works nicely. Featured with line editing, code completion, and more.

gore Yet another Go REPL that works nicely. Featured with line editing, code completion, and more. (Screencast taken with cho45/KeyCast) Usage gore Af

Jun 26, 2022
This is a simple text completion/editing/auto-correction tool I created in Go.
This is a simple text completion/editing/auto-correction tool I created in Go.

Auto Text Completion Tool This is a simple text completion/editing/auto-correction tool I created in Go. The tool receives the following arguments: Th

Oct 28, 2021
Fully featured Go (golang) command line option parser with built-in auto-completion support.

go-getoptions Go option parser inspired on the flexibility of Perl’s GetOpt::Long. Table of Contents Quick overview Examples Simple script Program wit

Jun 15, 2022
Fully featured Go (golang) command line option parser with built-in auto-completion support.

go-getoptions Go option parser inspired on the flexibility of Perl’s GetOpt::Long. Table of Contents Quick overview Examples Simple script Program wit

Jun 15, 2022