Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there a Golang terminal shell? Is it possible for a compiled language?

Tags:

shell

go

Recently I'm interested in Golang.

When I was learning Python I kicked off a terminal shell and just practised throwing it different data, files, making many trivial silly operations, it's such a nice way to interact with a new language and it's super helpful for writing new programs.

I wonder- I guess because Golang is a compiled language like Java it's not possible to have such a terminal shell. Is that right? If so- what's the real technical reason why it can't work?

like image 848
smatthewenglish Avatar asked Jun 01 '17 11:06

smatthewenglish


People also ask

Does Golang have interactive shell?

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

Is there a REPL for Golang?

Since Go programs are compiled, the language does not offer a REPL environment. The closest option would be the playground, it allows developers to run their Go code instantly.

What is the difference between Python shell and terminal?

The shell is a command-line interpreter. A command line, also known as a command prompt, is a type of interface. A terminal is a wrapper program that runs a shell and allows us to enter commands.


1 Answers

Take a look at gomacro

go get -u github.com/cosmos72/gomacro

~ $ gomacro
// GOMACRO, an interactive Go interpreter with generics and macros
// Copyright (C) 2018-2019 Massimiliano Ghilardi <https://github.com/cosmos72/gomacro>
// License MPL v2.0+: Mozilla Public License version 2.0 or later <http://mozilla.org/MPL/2.0/>
// This is free software with ABSOLUTELY NO WARRANTY.
//
// Type :help for help
gomacro> import "fmt"
gomacro> a := 10
gomacro> fmt.Println(a)
10
3   // int
<nil>   // error
gomacro>
like image 157
Robert Ranjan Avatar answered Nov 08 '22 05:11

Robert Ranjan