Gomacro, Go interpretor / REPL

Gomacro is a tool that allows you to run Go code by typing it in, like in Python, or you can load the code from a .go file, but it's a little different to Python.
It also allows you to call into Go packages, so it's a great help when learning Go.
To get it up and running:
Hopefully you have Go installed, because you need it to compile Gomacro. If you don't, go to golang.org and download the binaries for your system.
Now, you should set up your gopath environment variable. You don't have to, but it can make things easier.
This is basically where third-party binaries and source get stored.
Now, go to wherever you set up environment variables, on windows 7 this is under user accounts:change my environment variables, and select user variables.
Create a new directory somewhere, and set gopath to the new directory The directory can be pretty much anywhere, mine is "C:\py\go" for example. Just try to avoide spaces in the name.
Now, if you want to be able to open the command line and type gomacro and have it open like Python, you need another step.
Go back to the screen that lets you set your environment variables, go to user variables, and select path.
Click edit and add this to the end, without the quotes:
";%gopath%\bin"
Now, to install gomacro.
Type in this command:
"go get -u -ldflags -s -v github.com/cosmos72/gomacro"
If everything worked, you should be able to type gomacro and get a start up message.
If you want to import third-party packages, it works, but there's a bit of extra work if you're on windows. If you aren't, you can ignore this part.
First, open gomacro, and import the package, for example:
import "github.com/faiface/beep"
Gomacro will download the package and install it.
However, if you want to use the package, you need to recompile gomacro from the command line:
"go install -ldflags -s -v github.com/cosmos72/gomacro"
Now you can import the package again, and this time it should let you call functions inside the package, ETC.
Enjoy, HTH

-- 
Audiogames-reflector mailing list
Audiogames-reflector@sabahattin-gucukoglu.com
https://sabahattin-gucukoglu.com/cgi-bin/mailman/listinfo/audiogames-reflector
  • ... AudioGames . net Forum — Developers room : keithwipf1 via Audiogames-reflector
    • ... AudioGames . net Forum — Developers room : keithwipf1 via Audiogames-reflector
    • ... AudioGames . net Forum — Developers room : Ethin via Audiogames-reflector

Reply via email to