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?
Gosh is the interactive Golang shell. The goal is to provide an easy-to-use interactive execution environment.
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.
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.
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>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With