Now that you have ActiveGo installed (and if you haven’t downloaded it yet – you can get it here www.activestate.com/activego) – let’s quickly go over some of the great features available out of the box to help you get started developing with Go:
When learning any new language, the docs are a great place to start. We’ve bundled a wealth of Go documentation with the ActiveGo distribution–just launch it from the Windows Start menu to start up the app. After it launches, you can run sample programs, browse installed packages, and of course read individual package documentation.
Play with a Sample
Once you’ve launched the documentation app, you’ll notice that there is a sample playground on the left-hand side. You can choose from a list of available sample programs in the dropdown, and run them from within the window. You can even edit them and make changes!
Tip: The documentation app uses
godoc, a go command used to browse docs. You can use
godoc from the command line to get Unix
man style help on a package. Just type
godoc <packagename> to display help on that package from a command prompt.
Using goimports and golint
ActiveGo comes with many useful tools straight out of the box to help you keep your code clean and to catch errors early. In addition to the standard
gofmt command, ActiveGo ships with
golint to provide syntax checking for your projects. You can check your code for syntax errors simply by running
You can also clean up your import statements using goimports which will automatically add or remove unused packages. Just run
It’s worth noting that tools like
goimports will output to
stdout so you’ll need to direct them either to write to a new file or integrate directly with your editor to retain the changes that they make to your code.
Go’s built-in support for testing is a critical tool to help maintain your codebase, and ActiveGo expands on that by including additional packages like
errors and the invaluable
assert package that lets you integrate assertions into your test suites.
Within any test, you can add an assertion easily by using one of the many different comparison functions offered by this package. For example:
assert.NotNil(t, obj, "obj can not be nil")
It’s really that simple. Apply liberally throughout your tests to ensure your code is running the way it should be.
Debugging with Delve
When you do encounter issues in code and need to debug your programs we’ve included the Delve debugger to help you out. Delve works similarly to
gdb and lets you easily attach and debug your code. The easiest way to get started is to compile, run and attach in one step using:
From there, you can type ‘help’ for a list of the commands for setting breakpoints, watching variables, stepping through code, etc. If you want to debug a program that’s already running you can attach to the process using:
dlv attach <processid>
There’s a lot more to dig into with Delve and all the tools that come pre-bundled with ActiveGo. We’ve selected and included many of the most common database bindings, web tools, and packages for Big Data and microservices development. That list is by no means complete yet though so let us know what you’d like to see included!
Take some time to browse the documentation that outlines the included packages and tools, and if there’s anything you see that’s missing send us feedback at firstname.lastname@example.org.
We’re really excited about the ActiveGo beta release and want to work with you to create a distribution of Go that meets your needs – so please let us know how we can help.