Loading...

Follow JetBrains | Gogland Blog on Feedspot

Continue with Google
Continue with Facebook
or

Valid

Two weeks ago we released GoLand 2019.1 with built-in Memory, CPU, Mutex, and Block profilers, many new debugger features such as Smart Step Into, the new release also included Extract Interface refactoring, Nilness Analyzer, some handy updates for Go Modules, customizable UI themes, and even more goodies that were packed inside on top of that.

If you haven’t checked out these new features yet, head on over to our what’s new page. Or, if you would prefer to watch rather than read, then we have this short 5-minute video for you.

Let me just please take a second to say a big thank you to all the people, who have shared their product experience, feedback, and suggestions with us. Every insight we get from you helps us deliver to you an even better IDE with each release and EAP build!

In fact, we have been so inspired by your feedback, that we have already planned everything out for the upcoming release and want to take this time to share it with you! Let’s go behind the scenes and have a look at what’s coming your way.

Previously, as a token of our gratitude we presented the most active evaluators with a free 1-year subscription for GoLand. However, we have decided to add on top of that a special edition t-shirt. Of course with gophers on the front!

Meet the wonderful folks who have resolutely contributed their feedback to help us create an even better GoLand:

  • Roland Illig (YouTrack username: roland.illig)
  • Max Neverov (YouTrack username: nmax)
  • Gabriel Nelle (YouTrack username: nelle)
  • Mike Schinkel (YouTrack username: mikeschinkel)

You will receive an email with details soon.

Now on to our roadmap!

GoLand 2019.2 Roadmap

Please note we can’t guarantee that all of the features listed below will be included in GoLand 2019.2.

Remote development

The next release will get remote developing via Docker.

We had it in the plans for 2019.1, but, you know, sometimes things go wrong.

Support for Go 1.13 language changes Code Completion

Smart Code Completion for arguments of make/new calls.

Debugger
  • Better presentation for the Watches panel: Hex, Time format, and more.
  • An option to filter frames based on the contents of the stack to help make it easier for you to find specific stacks.
Refactorings
  • Quick-fixes for Change Signature refactoring: add/remove parameters and return parameters.
  • Support the extracting method with returns.
Intention Actions

We are planning to add more intention actions as well, such as:

  • Add method to the interface/structure.
  • Invert condition.
  • Split into two if.
  • Generate error handling code when an Unhandled Error is detected.
  • Several improvements for Fill Struct: option to choose fields to fill, fill with live-templates instead of just values, the ability to add a suggestion to Fill action to the auto-popup after adding.
UI
  • Improvements for the default color themes. Yes, finally!
  • Enhancement for Extract interface refactoring UI.
  • Code highlighting in the Quick Documentation.
Postfix Completion Templates
  • Custom Postfix Completion templates.
Editing
  • Highlighting for escape sequences in string literals.
Navigation
  • Go to implementation without a popup if there is that only option.
General
  • Auto-enable integrations for vgo/dep/vendoring.
  • New tools for predefined File Watchers.

BTW, the ideas for improvements we have, often come directly from the feedback we get from our users. Send your feature requests to us by dropping us a request in our bug tracker or by tweeting us at @GoLandIDE. Thank you!

Read Full Article
  • Show original
  • .
  • Share
  • .
  • Favorite
  • .
  • Email
  • .
  • Add Tags 

In today’s blog post, we’ll take a look at the new Profiler features of GoLand. We will split this article into two sections:
· General profiler usage in which we’ll cover the common features of the profiler across the various profiler methods.
· Using the different profiling methods in which we’ll cover how to use each individual profiling method and share code samples so you can try this on your own computer.

General profiler usage

The profiler supports capturing and displaying information for CPU, Memory, Mutex Contention, and Blocking profiling, which is covered in the section below. However, they all share a few common operations/UI elements so it’s best to cover them first.

The profiler works with the built-in Go tooling, namely the pprof profiling tool. It supports displaying information in several ways:

Using Flamegraphs

Using call trees

Using a list of elements sorted by their properties

Recent profiles list

It is also possible to see a list of previous runs and display them in the profiler view.

Importing profiling results from a different machine

If you run your pprof command on a different machine, then you can also import those results into the IDE. One way to obtain these profiles is to run either the tests or benchmarks from your application.

In the following example, we are running the BenchmarkInBoundsChannels benchmark function from all the packages in our project and saving the output in a file named cpu.out.
go test -bench=^BenchmarkInBoundsChannels$ -cpuprofile=cpu.out ./...

After that, we can use the Import Profiler Results | From File…

Custom profiler settings

The different profiler methods support configuration options as well. You can find these under Settings/Preferences | Build, Execution, Deployment | Go Profiler and select the profiling method you would like to configure, and then adjust it accordingly.

You can also have multiple profiler configurations for each profiling method, which enables you to better profile each application/test/benchmark according to your needs.

Using the different profiling methods

Let’s use the code below and run the various profiling methods available to us against it.

package main

import (
	"sync"
	"testing"
)

var pi []int

func printlner(i ...int) {
	pi = i
}

type mySliceType struct {
	valuesGuard *sync.Mutex
	values      []int
}

func (s mySliceType) Get(idx int) int {
	s.valuesGuard.Lock()
	defer s.valuesGuard.Unlock()

	checkBuffer(s.values, idx)

	return s.values[idx]
}

func (s mySliceType) GetCh(ch chan int, idx int) {
	s.valuesGuard.Lock()
	defer s.valuesGuard.Unlock()

	checkBuffer(s.values, idx)

	ch <- s.values[idx]
}

func newMySliceType(values []int) mySliceType {
	return mySliceType{
		valuesGuard: &sync.Mutex{},
		values:      values,
	}
}

func fillBuffer(slice []int) map[int]int {
	result := map[int]int{}
	for i := 0; i<100; i++ {
		for j :=0; j<len(slice); j++ {
			result[i * len(slice) + j] = slice[j]
		}
	}

	return result
}

func checkBuffer(slice []int, idx int) {
	buffer := make(map[int]int, len(slice) * 100)
	buffer = fillBuffer(slice)
	for i := range buffer {
		if i == idx {
			return
		}
	}
}

func slicerInBounds(slice mySliceType) {
	for i := 0; i < 8; i++ {
		a0 := slice.Get(i*8 + 0)
		a1 := slice.Get(i*8 + 1)
		a2 := slice.Get(i*8 + 2)
		a3 := slice.Get(i*8 + 3)
		a4 := slice.Get(i*8 + 4)
		a5 := slice.Get(i*8 + 5)
		a6 := slice.Get(i*8 + 6)
		a7 := slice.Get(i*8 + 7)

		printlner(a0, a1, a2, a3, a4, a5, a6, a7)
	}
}

func slicerInBoundsChannels(slice mySliceType) {
	ch := make(chan int, 8)
	for i := 0; i < 8; i++ {
		go slice.GetCh(ch, i*8+0)
		go slice.GetCh(ch, i*8+1)
		go slice.GetCh(ch, i*8+2)
		go slice.GetCh(ch, i*8+3)
		go slice.GetCh(ch, i*8+4)
		go slice.GetCh(ch, i*8+5)
		go slice.GetCh(ch, i*8+6)
		go slice.GetCh(ch, i*8+7)

		a0 := <-ch
		a1 := <-ch
		a2 := <-ch
		a3 := <-ch
		a4 := <-ch
		a5 := <-ch
		a6 := <-ch
		a7 := <-ch

		printlner(a0, a1, a2, a3, a4, a5, a6, a7)
	}
}

func BenchmarkInBounds(b *testing.B) {
	var mySlice []int
	for i := 0; i < 99; i++ {
		mySlice = append(mySlice, i)
	}
	ms := newMySliceType(mySlice)
	b.ResetTimer()
	for i := 0; i < b.N; i++ {
		slicerInBounds(ms)
	}
}

func BenchmarkInBoundsChannels(b *testing.B) {
	var mySlice []int
	for i := 0; i < 99; i++ {
		mySlice = append(mySlice, i)
	}
	ms := newMySliceType(mySlice)
	b.ResetTimer()
	for i := 0; i < b.N; i++ {
		slicerInBoundsChannels(ms)
	}
}
CPU Profiling

As the name suggests, this profiling method allows you to profile where the time is spent in your application. To run it, you can use the Run CPU Profile action in the application. The views will then display the time spent by the CPU to execute each function call, as well as the time spent for the CPU to execute subsequent calls.


This profiler does not currently support any special configuration options.

Memory Profiling

This profiler allows you to identify where your application is allocating memory and how much. You can see the in-use memory space, in-use objects, object allocations, and the allocated space.

You can configure this profiler to mark one allocation for every 512 KB of allocated memory, regardless of whether it was made by one or more allocations. The default is set to 512 KB. Setting it to 1 will show all the allocations individually.

Mutex Contention Profiling

This profiling method is useful when you want to detect whether a contention happens in your application and for how long. It will help you detect bottlenecks in your applications caused by code waiting for mutexes to be released/acquired, which might not be immediately obvious by just looking at the code itself or at the CPU profile.

You can configure this profiler to show only a certain fraction of the contentions happening. The default is to show every contention.

Blocking Profiling

Last but not least, the blocking profiler method allows users to understand the goroutines that could have run but were blocked by other goroutines. This is similar to the Mutex profiling method, as it displays the contents or the delay caused, but it works at the goroutines level instead of the mutex level.

You can configure this profiler to only show blocking events longer than a certain time, in nanoseconds. The default value will show every blocking event that happened for more than a nanosecond.

This concludes our blog post. I hope you learned a bit about how the new profiler feature in GoLand can help you detect and fix bottlenecks in your applications using the CPU, Mutex, or Blocking profiling methods, and how to detect memory leaks and optimize memory consumption using the Memory profiling method.

As usual, please let us know your feedback in the comments section below, on Twitter, or on our issue tracker. Suggestions for any topics that you would like to see covered in future posts are also very welcome.

Read Full Article
  • Show original
  • .
  • Share
  • .
  • Favorite
  • .
  • Email
  • .
  • Add Tags 
JetBrains | Gogland Blog by Ekaterina Zharova - 1M ago

We’ve just released GoLand 2019.1 that we want to introduce to you!

GoLand 2019.1 gets built-in Memory, CPU, Block and Mutex profilers, enhances the debugger with advanced features, adds new refactorings, and alerts you about potential errors of using nil in expressions in a variety of ways.

It also lets you download and install any Go SDK right from the IDE, and makes you feel right at home with support for customizable UI themes and the new pre-configured Sublime Text keymap.

That doesn’t even begin to describe everything that GoLand has to offer. Read on for the juicy details, or go to our What’s New page to learn more about what we’ve done for Go Modules, navigation, Intention Actions, Version Control, web development, and databases.

Download GoLand 2019.1

BTW, if you haven’t tried GoLand yet, get your free 30-day trial to evaluate the new features.
Read about the highlights, or check them out in this quick demo:

What's New in GoLand 2019.1 - YouTube

Profiling

Run the built-in Memory, CPU, Mutex, and Block profilers in one click. Review and sort the analysis results in a dedicated tool window, all from within GoLand.

Debugger
  • Debugging a chain of calls and nested method calls is much easier now with the new debugger action, Smart Step Into.
  • The debugger displays goroutines instead of threads (and vice versa). Choose how to show int variables: as binary, decimal, or hex.
  • Copy Stack, available in the Debugger tab by right-clicking on the goroutine list, copies the whole frame stack to the copy/paste buffer. Magic!
  • Run to Cursor is available as a mouse gesture.
  • Windows minidumps are supported.
  • Run/Debug Configurations can now be run with sudo.
Refactorings
  • A new Extract Interface refactoring helps you quickly create a new interface based on the selected type.
  • The Rename refactoring now includes the capability to rename methods declared in interfaces.
Code Inspections
  • Nilness Analyzer is a new set of code inspections designed to instantly detect whether variables might have nil or not nil values in a variety of situations.
  • Multiple defaults in switch code inspection warns you about redundant default cases in a switch statement and lets you quickly navigate to the duplicated default.
New UI Themes and customization support

All the new 2019.1 versions of IntelliJ IDEA-based IDEs you can fully customize the colors of all the UI elements. Really, you can change the color of anything!

We may have got a little carried away, and accidentally created three new themes: Dark Purple, Cyan Light, and Gray themes. Enjoy!

Go SDK installation from the IDE

When creating a new project in GoLand, there is now the option to download and install any required version of the SDK, including Beta and RC versions.

Different handy changes
  • New pre-configured Sublime Text keymap available from Preferences | Settings | Keymap, and a VS Code keymap, available via this plugin.
  • Recent locations popup helps navigation around the project by providing a list of recently visited/changed code locations as code snippets.
  • Project templates for web development, such as React App, React Native, HTML5 Boilerplate, and Foundation, are all available from the Welcome screen.
  • New option to export Code Style settings to JSON available under Preferences /Settings | Editor | Code Style.
  • Settings of JetBrains-made plugins are searchable in the Preferences/Settings dialog.
  • The files and folders that are ignored are shown as olive-green in the Project view.
  • Copy & paste text to the Blank Diff window by dragging a file onto it.
New Intention Actions
  • Set of intention actions to help you reformat declarations the way you want: Settings/Preferences | Editor | Intentions | Declaration.
  • Export intention action lets you export a private function, type, or field without switching between packages.
Go Modules
  • We’ve added code completion for non-imported Go modules.
  • Go Modules projects template get a new Vendoring mode checkbox.
Version control improvements
  • An Uncheck all checkbox for Partial Git commits (git add -p) lets you uncheck all the code chunks at once.
  • Fixup and Squash Into actions to create commits with the correct fixup! and squash! messages
  • The Mark Branches that have incoming/outgoing commits in the Branches popup says it all.
  • Display the initials of authors instead or their full name in the VCS annotation.
Web development
  • Set of refactorings, intention actions, and quick-fixes to help you start easily destructuring objects and arrays in your code.
  • Convert to async function intention action helps change a function that returns a Promise to an async function with async/await.
  • The docs for HTML and CSS now show descriptions from MDN and information on the browser support.
  • When you run tests with Jest, Karma, Mocha, or Protractor and some of them fail, the IDE highlights the code that failed in the editor.
Databases
  • The Remember password feature now has two options for storing passwords: Forever and For session.
  • Support for Greenplum, Vertica, and Apache Hive databases.
  • A completely reworked connection dialog.
  • New keep-alive and auto-disconnect options.
  • The filter in the data editor suggests the value from the clipboard.

Last but not least, the ideas for improvements we have often come directly from the feedback we get from our users. Share your feedback with us by dropping us a request in our bug tracker or by tweeting us at @GoLandIDE. Thank you!

Read Full Article
  • Show original
  • .
  • Share
  • .
  • Favorite
  • .
  • Email
  • .
  • Add Tags 

In today’s post, I want to look at a new code analysis tool that has been present from the 2019.1 release of GoLand. It’s named Nilness Analyzer, and you can find it under Settings/Preferences | Editor | Inspections | Go | Probable bugs | Nilness analyzer.

This inspection helps us detect cases when we want to access information that could cause a panic, such as calling methods on a nil interface, using methods or members of nil structures, accessing nil slices, and so on.

Because this inspection is native to our IDEs, it will run as you type, which means that it will catch errors as soon as they are written, making it really quick during the development cycle to find issues, before even running a test suite or the application itself.

Let’s jump into some examples of cases it detects and how they look:

As you can see, the IDE tells us pretty quickly that we are trying to access an element from a slice that’s nil, which would result in a panic at runtime.

This works in more complex cases. For example, if you want to access a field of a variable which is a pointer and you don’t check the corresponding error for it, then this could also produce a runtime panic.

Cases like comparisons that will always be true or false can also be caught by the new inspection.

Ever wondered if you call a method on a nil pointer receiver?

Or when conditions might lead to a runtime panic because they test for the wrong nil value.

That’s it for today. I hope you like the new inspection.

Please let us know in the comments section below, on Twitter, or our issue tracker, about your thoughts on this, and what you would like to see from us in the future, be it feature request, article, or if you have any issues that would like to get fixed.

Read Full Article
  • Show original
  • .
  • Share
  • .
  • Favorite
  • .
  • Email
  • .
  • Add Tags 

GoLand 2019.1 Release Candidate is out, it means that we’re now in sight of the finish line, so if no critical issues are found, the release will go public.

Download GoLand 2019.1 RC

Get this RC build via our Toolbox App, from the website, as a snap package (for Linux), or directly from GoLand – just select Automatically check updates for Early Access Program in Preferences / Settings | Appearance & Behavior | System Settings | Updates.

Please note that to use GoLand 2019.1 RC, you need to have an active subscription or start a 30-day evaluation period. In addition, we’ve stopped providing nightly builds until the next Early Access Program opens (for 2019.2).

This RC build brings useful tiny changes and bug-fixes, mostly for the debugger:

GO-7021 — The UI doesn’t freeze on auto-import anymore.

GO-6662, GO-6345 — The Variables tab in the debugger now displays the types contained in an interface and shows the address for the pointers inside a type.

GO-6989 — Unreadable variables are hidden in the debugger now.

GO-7062
— Navigation to struct fields in the debugger is working correctly.

GO-6509
— Setting the value for struct fields, pointers, and interface values in the debugger works as expected.

We love to hear from you! Do share your feedback with us: here in the comments, on Twitter, or our bug tracker.

Read Full Article
  • Show original
  • .
  • Share
  • .
  • Favorite
  • .
  • Email
  • .
  • Add Tags 
JetBrains | Gogland Blog by Ekaterina Zharova - 2M ago

The upcoming GoLand 2019.1 is now in Beta!

For three months now, our team has worked hard to turn our roadmap into reality, to meet your expectations, and hopefully to feel that pleasant fatigue that you get after you’ve done even more than planned.

After this Beta milestone, we will mostly focus on eliminating bugs and polishing UI elements and everything around until the major release.

Get this Beta build via our Toolbox App, from the website, as a snap package (for Linux), or directly from GoLand – just select Automatically check updates for Early Access Program in Preferences / Settings | Appearance & Behavior | System Settings | Updates.

Download GoLand 2019.1 BETA

Before I give you the headliners of this release, let me just note that the Beta is quite stable in comparison to our other EAP builds, though some clumsy things may still pop up here and there.

Click on a topic below to learn more about a specific area you’re interested in, or read through the whole blog post to get yourself up to speed with all the new improvements:

Built-in Heap, CPU, Mutex, and Block profilers

We’re not ashamed to say that GoLand 2019.1 takes your profiling experience to a whole new level of productivity, and we can back this claim up with hard data.

To expand its tooling support, GoLand now integrates with Memory, CPU, Mutex, and Blocking profilers. This means you can start profiling your application in one click, right from the IDE, and then review the analysis results in a dedicated tool window (View | Tool Windows | Profiler).

Sort the results by special metrics appropriate for each type of profiler. With Flame Chart, Call Tree, and Method List tabs as well as navigation to the source code from any method, you can identify performance problems much quicker than before.

Smart Step Into

A new debugger action, Smart Step Into, is one more thing that makes us proud as it saves you plenty of time while debugging a chain of calls and nested method calls. Step into arbitrary calls in an expression, automatically stepping over the methods which you are not interested in. To invoke Smart Step Into, press Shift+F7 or select Smart Step Into from the Run menu.

Read this blog post to learn more about the new debugging features in GoLand 2019.

Extract Interface refactoring

The Extract Interface refactoring helps you quickly create a new interface based on the selected type. It shows a list of suggested members to be transferred to the new interface. You can specify a name for the interface and choose the file, directory, or package where it should be placed.

To learn more, see Extract interface refactoring in GoLand 2019.1.

More capable Rename

The Rename refactoring can now rename methods declared in interfaces. When renaming such methods, GoLand will offer to rename their implementations as well.

Nilness Analyzer

Go gives us many ways to make the zero value useful, but the more opportunities we have, the easier it is to fall into a trap.

Our brand new Nilness Analyzer is a set of code inspections designed to instantly detect whether variables might have nil or not nil values in a variety of cases.

It warns you about:

  • redundant comparisons such as v == nil if v is known to be always nil or not nil.
  • trying to access a variable pointing to nothing and faced with ‘nil pointer dereference’.
  • unintentionally raising panics when indexing a nil slice.
  • and much more.

Handy general changes

In the upcoming GoLand 2019.1, you can fully manage your Go SDK downloads and installations right from the IDE.

The Go Modules projects template gets a new Vendoring mode checkbox, which lets you use libraries from the vendor folder without any external dependencies or connection to the Internet. The same checkbox is also available via settings in Preferences | Go | Go Modules (vgo).

To learn more about using vendoring with Go Modules, please read this article from the Go team.

Feel right at home with the new pre-configured Sublime Text keymap available at Preferences | Settings | Keymap, and the pre-configured VS Code keymap available via this plugin.

Project templates for web development (such as React App, React Native, HTML5 Boilerplate, and Foundation) are now available from the Welcome screen.

Debugger updates Goroutines instead of threads

The debugger output now displays goroutines instead of threads. Switch between them, quickly navigate to standard Go libraries, and get more information about how your code is being executed.

View int as binary, decimal, or hex

You can now choose whether to display int variables in the debugger views as binary, decimal, or hex. Right-click a variable and select the appropriate or preferred option under View as.

Support for minidumps

In addition to exploring core dumps, now you can also open and analyze windows minidumps right in the IDE. Like with core dumps, it’s as easy as selecting Run | Open Core Dump.

To learn more, read Debugging in GoLand — Windows Minidumps on our blog.

Copy Stack

Copy Stack, available in the Debugger tab by right-clicking on the goroutine list, copies the whole frame stack to the clipboard.

Run to Cursor as mouse gesture

The Run to Cursor action is now available by clicking on a line number while debugging. Hover over a line to highlight it. Click a line number to Run to Cursor.

Run Go configurations with sudo

Run/Debug Configurations can now be run with sudo. It allows you to debug applications which require privileged operations as a user.

Intention Actions

We’ve added a set of intention actions to help you reformat declarations the way you want: add or remove parentheses to a declaration, merge a declaration up, split a declaration into two group, by comma, and more.

For the complete list of available actions and their detailed descriptions, go to the Declaration section of Go in Settings/Preferences | Editor | Intentions.

A new Export intention action lets you export a private function, type, or field without switching between packages. In addition, GoLand now resolves references to unexported symbols, but it will still notify you that it’s an error.

VCS updates

The new Uncheck all checkbox for Partial Git commits (git add -p) lets you uncheck all the code chunks at once, and lets you choose the ones you want to commit, too.

The Log tab in VCS gets Fixup and Squash Into actions to create commits with the correct fixup! and squash! messages.

You can now use the context menu on the Log tab to cherry-pick selected files from the commit.

If you go to Preferences/Settings | Version Control | Git and select Mark Branches that have incoming/outgoing commits in the Branches popup, the IDE will indicate if the incoming and outgoing commits are available for individual branches in the Branches popup.

The Recently Deleted node in the Shelf tree shows all the recently deleted files and helps you restore any of them.

In addition, the IDE gives you a choice to display the initials of authors instead or their full names in the VCS annotations.

Even more nice things

Now it is possible to export Code Style settings to JSON. This is in addition to the already available option export to XML, available under Preferences /Settings | Editor | Code Style.

Copy & paste text to the Blank Diff window by dragging a file to it. Alternatively, you can do the same through file navigation.

In the Project view, the files and folders that are ignored now use olive-green to help you distinguish them from other files. You can modify their color in Preferences/Settings | Version Control | File Status Color.

That’s all! Download the Beta version from the website, via our Toolbox App, or right from the IDE. And do share your feedback with us: here in comments, in our Twitter, or our bug tracker.

Read Full Article
  • Show original
  • .
  • Share
  • .
  • Favorite
  • .
  • Email
  • .
  • Add Tags 

A while back we talked about debugging the core dumps produced on Linux systems.
Since then, the IDE has had an update that allows it to debug the equivalent memory dumps produced on Windows systems, called minidumps. As with core dumps, minidumps can be analyzed on any operating system, not just on Windows. Please note that you will need GoLand 2019.1 or higher to use this feature.

Let’s start with getting the minidump itself. As with coredumps, set the Output Directory of the run configuration; this is where the binary will be created.

Then, start the application and use it as usual. When you are ready, open the Task Manager, go to Processes, select your application and then right-click it and select Create dump file. This will give you a location for the minidump file, such as %TMP%\<binary-name>.DMP

Now, go to Run | Open Core Dump… , select the application binary, the minidump generated above, and the IDE will show the debugger window.

That’s it for today. Please let us know what feedback you have in the comments section below, on Twitter, or on our issue tracker. We are also looking for your thoughts on what topics you would like to see covered next.

Read Full Article
  • Show original
  • .
  • Share
  • .
  • Favorite
  • .
  • Email
  • .
  • Add Tags 

GoLand 2019.1 EAP 8 is here!

Get this new EAP build via our Toolbox App, from the website, as a snap package (for Linux), or directly from GoLand – just select Automatically check updates for Early Access Program in Preferences / Settings | Appearance & Behavior | System Settings | Updates.

Download GoLand 2019.1 EAP 8

Built-in Heap, Mutex, and Block Profilers

Profiling is the best way – and sometimes the only way – to know the real performance of your application.

That’s why we are happy to let you know that GoLand has expanded its tooling support by integrating with Memory, Mutex, and Blocking profilers in addition to the CPU profiler.

You can run profilers right from the IDE, and then review the analysis results in a dedicated tool window (View | Tool Windows | Performance Profiler).

To run the profiler, use the new Run with Profiler button and choose the required configuration in the navigation toolbar. Alternatively, select any of new actions in the run menu, which appears when you click on the run icon in the left gutter.

To get a better understanding of the possible performance issues in your code, sort the results by metrics. Each particular profiler has different metrics appropriate for its type via the Metric’s popup menu.

The Memory Profiler lets you sort and explore the results by Allocated objects, Allocated space, In-use objects, and In-use space. The Blocking Profiler and Mutex Profiler provide two options for metrics: Contentions and Delay.

In addition, use the Flame Chart, Call Tree and Method List tabs to identify performance problems more quickly. Right-click on any method in these tabs to switch focus to its data in the Methods List or in the Flame Chart, or vice versa, or even navigate to the source code to inspect the issues in the code base.

We will cover new profiler features in greater details soon, so stay tuned!

Support for Minidumps

We’ve enhanced dumps support in GoLand 2019.1. In addition to exploring core dumps, now you can also open and analyze windows minidumps right in the IDE. Like with core dumps, all you need to do is to select Run | Open Core Dump.

Note that minidumps are available only on Windows machines by default. However, you can analyze them on any flavor of macOS, Windows, or Linux.

Noticeable bug-fixes:

GO-6517 — The debugger supports attaching and detaching to the same remote process multiple times without terminating the process.

Remember that we always appreciate your feedback, so please share it with us here in the comments, on Twitter, or in our issue tracker.

Read Full Article
  • Show original
  • .
  • Share
  • .
  • Favorite
  • .
  • Email
  • .
  • Add Tags 

In today’s article, we will talk about the Extract Interface refactoring, a new refactoring available since GoLand 2019.1.

This refactoring allows us to take a type and extract all the method definitions that we need, then create a new interface from them. This operation is particularly useful when going from a single implementation to using multiple implementations, such as in the example below.

To invoke this, you can use the Refactor This shortcut, Ctrl+Alt+Shift+T on Windows/Linux or ^T on macOS.

The Extract Interface dialog allows us to select any method from the existing type and control where will the interface be extracted. As such, you can create the interface in the current file/package, by default, or in a new file/package or existing ones but different than the current ones. You can also control if the methods should be exported or not, in case you do not want for external packages to be able to implement the interface.

That’s it for today. We learned how to use a new and powerful refactoring feature that will help us as the code base grows. Please let us know your feedback in the comments section below, on Twitter, or on our issue tracker.

Read Full Article
  • Show original
  • .
  • Share
  • .
  • Favorite
  • .
  • Email
  • .
  • Add Tags 

Today we start the last article in the series of debugging with GoLand. Previously we addressed points such as configuring the debugger and the debugging session, how to control the debugger execution flow and configure breakpoints, and what are some of the latest improvements in the upcoming 2019.1 version.

In today’s article, we will talk about two advanced debugging features of GoLand: Core Dump debugging and using Mozilla rr, a reversible debugger.

Debugging core dumps

Core dumps are memory snapshots of running applications taken at a certain point in time. They can help us visualize all the goroutines present, with all the values for the variables, as well as the current execution point for each active goroutine.

Right now, GoLand supports only Core Dumps taken on Linux systems, but it can read and analyze them on any operating system.

There are two ways to obtain a core dump. If we want to see the in-memory values as the process terminates because of a crash, we need to set the ulimit to be reasonably high, e.g., sudo ulimit -c unlimited, and have the following environment variable configured GOTRACEBACK=crash.  This will enable Go applications to crash with a stacktrace printed and with a core dump file written.

To be able to get core dumps from a running process without having to crash it, we need to have gdb installed on the system and run these commands:

sudo ulimit -c unlimited
echo 0 | sudo tee -a /proc/sys/kernel/yama/ptrace_scope

Note that this value will be reset on system restart and you’ll need to configure it again.

To generate and use the core dump, we need to configure the IDE to save the binary in a known location, such as our project root directory.


After that, we can start the application as usual, and start sending requests to it. Next, after we determine the process id of the application, we can invoke gcore <pid> and get the dump file.

To investigate the core dump in the IDE, we can either use the binary and core dump generated from the remote server or the binary and core dump produced by running the above commands. Then go to Run | Open Core Dump… and select both the executable and the core dump file. This will open the debugger interface and let you see the list of running goroutines, threads, the values for all variables. You can use the Evaluate feature to understand what the application is currently doing.

Using core dumps helps you determine where goroutines are stuck, how many of them there are, and which values they have in memory while the issue happens.

Mozilla rr reversible debugger

However, using core dumps is a static process. Sometimes a bug is difficult to replicate, and it takes many debugging sessions to reproduce it, and then many more to see if it’s fixed.

Enter reversible debuggers. These debuggers allow us not only to step forward in execution but also to go back and effectively undo all the operations between steps.

Delve, the Go debugger used by GoLand has support for such functionality by using Mozilla’s rr project. From the description of the rr project, its mission is to allow the “replay the failing execution repeatedly under a debugger until it has been completely understood.”

Another benefit of using rr is that it has a low overhead of execution during the recording part of the session. This means it can be used on production systems or production-like canary systems to catch bugs that cannot be otherwise replicated, and then to investigate them in the comfort of a development environment.

Let’s see this in action.

Before we start, there are some strict limitations of where rr can run which should be known ahead of time. It can only run on Linux with some restrictions regarding the hardware/virtual machine capabilities. These affect the usefulness of this debugging solution. However, once an environment meets the requirements, it will become one of the most powerful solutions available.

After installing rr, we need to run a couple of commands so that rr can perform the recording part:

echo -1 | sudo tee -a /proc/sys/kernel/perf_event_paranoid
echo 0 | sudo tee -a /proc/sys/kernel/kptr_restrict

These settings are not permanent and need to be applied again if the machine is restarted.

Click the green arrow next to the main function, and select Record and Debug… This will launch the required compile step and then the debugger using the rr backend.

For applications that are designed to run continuously, such as the web server in the example code, we need to stop the debugger and then select Run | Debug Saved Trace… By default, the latest rr session will be selected so we can click the OK button to start the debugging session.

For applications that do terminate, like CLI applications, GoLand will automatically start the replay session.

Here is where the debugging session is different from the regular debugging session. The debugger will not stop at breakpoints during the “record” part of the session; it will only do so during the replay part. If no breakpoints are set, then the debugger will just end, and we’ll need to replay the last session manually, again with breakpoints required to be present – otherwise this will finish the replay session and exit without stopping.

If a breakpoint is present, then the debugger will stop at it, and it will offer a similar experience to a normal debugger session.

As for the “reversible” part, this is where the best part of using rr comes into play. If a breakpoint is placed before the current execution point, then we can use the Rewind feature to go back to it and retry the execution from there. Features such as watching variables or evaluating expressions will work as well.

I hope that this post will help you discover a new powerful tool to have under your belt, which can speed up finding and fixing bugs in your applications.

This wraps up our series on debugging with GoLand. As usual, if you have any comments or would like to learn more about this, please use the comments section below, or reach out to us on Twitter, or on our issue tracker.

Read Full Article

Read for later

Articles marked as Favorite are saved for later viewing.
close
  • Show original
  • .
  • Share
  • .
  • Favorite
  • .
  • Email
  • .
  • Add Tags 

Separate tags by commas
To access this feature, please upgrade your account.
Start your free month
Free Preview