gore

package module
v0.4.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 28, 2019 License: MIT Imports: 33 Imported by: 3

README

gore Travis Build Status

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)
  • Pretty printing (pp or spew recommended)
  • Showing documents (requires godoc)
  • 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 (requires godoc)
:help                   List commands
:quit                   Quit the session

Installation

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

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

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

Also recommended:

go get -u github.com/mdempsky/gocode   # for code completion
go get -u github.com/k0kubun/pp        # or github.com/davecgh/go-spew/spew
go get -u golang.org/x/tools/cmd/godoc # for using with the :doc colon-command

FAQ/Caveats

  • If you see too many arguments in call to mainScope.LookupParent while installing gore, run go get -u golang.org/x/tools/go/types.
  • gore runs code using go run for each input. If you have entered time-consuming code, gore will run it for each input and take some time.
  • To import a local package, first fetch it with go get my/package, then :import will work properly.

License

The MIT License.

Author

motemen <motemen@gmail.com>

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Run added in v0.4.0

func Run(args []string) error

Run gore.

Types

type Error

type Error string

Error ...

const (
	ErrContinue Error = "<continue input>"
	ErrQuit     Error = "<quit session>"
	ErrCmdRun   Error = "<command failed>"
)

Errors

func (Error) Error

func (e Error) Error() string

type Session

type Session struct {
	// contains filtered or unexported fields
}

Session ...

func NewSession

func NewSession(stdout, stderr io.Writer) (*Session, error)

NewSession creates a new Session.

func (*Session) Clear added in v0.4.0

func (s *Session) Clear() error

Clear the temporary directory.

func (*Session) Eval

func (s *Session) Eval(in string) error

Eval the input.

func (*Session) Run

func (s *Session) Run() error

Run the session.

Directories

Path Synopsis
cmd

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL