Git Product home page Git Product logo

gosh's Introduction

Gosh: interactive shell for golang

Gosh is the interactive Golang shell. The goal is to provide an easy-to-use interactive execution environment.

https://secure.travis-ci.org/mkouhei/gosh.png https://coveralls.io/repos/mkouhei/gosh/badge.png?branch=master Documentation Status

Documentation

http://gosh.readthedocs.org/

Features

  • Interactive shell
  • Enable to omit the main function
  • Enable to omit package statement
  • Enable to omit the import statement of standard library
  • Enable to Import libraries of non-standard library
  • Enable to re-declare function, type
  • Ignoring duplicate import package
  • Ignoring unused import package

Requirements

  • Golang >= 1.2
  • goimports command
    • We recommend that you install goimports to $PATH in advance.
    • Installing automatically if the command is not found in $PATH (>= v0.3.0).
    • However, the time until the installation is complete in this case,
      you will be waiting for the launch of "Gosh" process.

for documentation

  • libpython2.7-dev
  • libjpeg9-dev

Installation

Debian

Install the following packages

  • golang
  • golang-go.tools (recommended)

Set GOPATH:

$ install -d /path/to/gopath
$ export GOPATH=/path/to/gopath

If you install goimports in advance (recommended):

$ sudo apt-get install -y golang-go.tools

Install Gosh to GOPATH:

$ go get github.com/mkouhei/gosh

OS X

Install the follow packages with Homebrew.

  • Go
  • Mercurial (with Homebrew)

Set GOPATH:

$ install -d /path/to/gopath
$ export GOPATH=/path/to/gopath

If you install goimports in advance (recommend):

$ export PATH=${GOPATH}/bin:$PATH
$ go get golang.org/x/tools/cmd/goimports

Install the Gosh:

$ go get github.com/mkouhei/gosh

Basic usage

Examples:

$ $GOPATH/bin/gosh
>>> import "fmt"
>>> func main() {
>>> fmt.Println("hello")
>>> }
hello
>>>

or:

$ $GOPATH/bin/gosh
>>> func main() {
>>> fmt.Println("hello")
>>> }
hello
>>>

Note

Enabled to omit import statement for standard packages.

Enabled to import non-standard packages

Example of using non-standard package:

>>> import "net/http"
>>> import "example.org/somepkg"
>>> func main() {
>>> r, _ := http.Get("http://example.org/some")
>>> defer r.Body.Close()
>>> p, _ := somepkg.Reader(r.Body)
>>> fmt.Println(p)
>>> }
(print some payload)

Usage when omitting main function declarations

Example:

$ $GOPATH/bin/gosh
>>> i := 1
>>> i++
>>> fmt.Println(i)
2
>>>

Terminate Gosh to reset main declarations or declare func main() without body:

$ $GOSH/bin/gosh
>>> i := i
>>> fmt.Println(i)
1
>>> func main() {}
>>> fmt.Println(i)
[error] # command-line-arguments
./gosh_tmp.go:8: undefined: i
>>>

Limitations

  • fmt.Print* are executed only once.

Known issues

Fail to evaluate when there are declared and not used valiables.:

$ $GOPATH/bin/gosh
>>> i := 1
>>> fmt.Println("hello")
>>>

Roadmap

  • Tab completion
  • Enable to omit import statement for global(system) installed packages

License

Gosh is licensed under GPLv3.

gosh's People

Contributors

chuenlye avatar coolbrg avatar mkouhei avatar papriwalprateek avatar seanknox avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.