gore

package module
v0.4.1 Latest Latest
Warning

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

Go to latest
Published: Mar 30, 2019 License: MIT Imports: 32 Imported by: 0

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

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

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

View Source
const Version = "0.4.1"

Version of gore.

Variables

This section is empty.

Functions

This section is empty.

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 Gore

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

Gore ...

func New

func New(opts ...Option) *Gore

New Gore

func (*Gore) Run

func (g *Gore) Run() error

Run ...

type Option

type Option func(*Gore)

Option for Gore

func AutoImport

func AutoImport(autoImport bool) Option

AutoImport option

func ErrWriter

func ErrWriter(errWriter io.Writer) Option

ErrWriter option

func ExtFiles

func ExtFiles(extFiles string) Option

ExtFiles option

func OutWriter

func OutWriter(outWriter io.Writer) Option

OutWriter option

func PackageName

func PackageName(packageName string) Option

PackageName option

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

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