{"id":596699,"date":"2025-09-08T19:05:06","date_gmt":"2025-09-08T18:05:06","guid":{"rendered":"https:\/\/blog.jetbrains.com\/?post_type=go&#038;p=596699"},"modified":"2025-09-15T15:53:33","modified_gmt":"2025-09-15T14:53:33","slug":"goland-can-do-that-ten-secret-superpowers-you-might-not-know","status":"publish","type":"go","link":"https:\/\/blog.jetbrains.com\/zh-hans\/go\/2025\/09\/08\/goland-can-do-that-ten-secret-superpowers-you-might-not-know","title":{"rendered":"\u201cGoLand Can Do That?\u201d Ten Secret Superpowers You Might Not Know"},"content":{"rendered":"\n<p><em>Note: This is a guest post from John Arundel, a Go writer and teacher who blogs at <\/em><a href=\"https:\/\/bitfieldconsulting.com\" target=\"_blank\" rel=\"noopener\"><em>bitfieldconsulting.com<\/em><\/a><em>. His most recent book is <\/em><a href=\"https:\/\/bitfieldconsulting.com\/books\/deeper\" target=\"_blank\" rel=\"noopener\"><em>The Deeper Love of Go<\/em><\/a>.<\/p>\n\n\n\n<p>How do you break it to someone that they&#8217;ve wasted most of their life? Well, I worked with a guy who didn&#8217;t know how to copy and paste. Every time he wanted to move some code, he&#8217;d delete it and then grimly re-type the whole thing somewhere else, as I watched in silent dismay: \u201cHow do I tell him?\u201d<\/p>\n\n\n\n<p>It wasn&#8217;t that he didn&#8217;t want to be able to copy and paste. He just had no idea that he could \u2013 he&#8217;d never taken the time to fiddle around and find out.<\/p>\n\n\n\n<p>That guy is all of us, in a way. Even if we can copy and paste, what other editor superpowers are we missing out on? And how much time are we wasting by not knowing about them? I&#8217;m just going to confidently say \u201cSome\u201d, right?<\/p>\n\n\n\n<p>A modern IDE is more than just a text editor \u2013 it&#8217;s also a file manager, debugger, linter, AI assistant, and so on. Even better, an IDE like <a href=\"https:\/\/www.jetbrains.com\/go\/\" target=\"_blank\" rel=\"noopener\">GoLand<\/a> actually understands<em> Go<\/em>, so it can make suggestions as you type, highlight errors, annotate your code, and refactor automatically.<\/p>\n\n\n\n<p>Here are ten things you might not know GoLand can do, and each one will make you more productive as a Go developer.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Search everywhere<\/h2>\n\n\n\n<p>90% of software engineering is just finding stuff, I reckon: where is that function defined? Where did I put that struct type?<\/p>\n\n\n\n<p>Double-tap the <em>Shift<\/em> key in GoLand and type to search everywhere\u201d: definitions, symbols, filenames, or even editor features. For example, enter <code>search<\/code> to see all search-related settings.<\/p>\n\n\n\n<figure class=\"wp-block-image size-full is-resized\"><img decoding=\"async\" loading=\"lazy\" width=\"1600\" height=\"800\" src=\"https:\/\/blog.jetbrains.com\/wp-content\/uploads\/2025\/09\/search_everywhere.png\" alt=\"\" class=\"wp-image-596700\" style=\"aspect-ratio:2;width:840px;height:auto\"\/><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\">Go to implementation<\/h2>\n\n\n\n<p><em>Cmd-click<\/em> a function or variable name and GoLand will take you straight to its definition, even in another package or file (or even the standard library or your dependencies). And you can keep drilling down further until you find what you need, then use <em>Cmd-[<\/em> to jump back.<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img decoding=\"async\" loading=\"lazy\" width=\"1600\" height=\"800\" src=\"https:\/\/blog.jetbrains.com\/wp-content\/uploads\/2025\/09\/go_to_implementation.png\" alt=\"\" class=\"wp-image-596711\"\/><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\">Structure view<\/h2>\n\n\n\n<p>For a high-level overview of your constants, functions, types, and their associated methods, press <em>Cmd-F12<\/em> to open the <em>Structure<\/em> view of your file or package. Click on any item to go to its definition.<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img decoding=\"async\" loading=\"lazy\" width=\"1600\" height=\"800\" src=\"https:\/\/blog.jetbrains.com\/wp-content\/uploads\/2025\/09\/structure_view.png\" alt=\"\" class=\"wp-image-596722\"\/><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\">Parameter names<\/h2>\n\n\n\n<p>GoLand shows inline hints for function calls, giving parameter names for each function argument. This makes reading code easier, especially when arguments are <code>nil<\/code>, for example. You&#8217;ll also see name hints for results in a <code>return<\/code> statement, and field names for struct literals that omit them.<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img decoding=\"async\" loading=\"lazy\" width=\"1600\" height=\"800\" src=\"https:\/\/blog.jetbrains.com\/wp-content\/uploads\/2025\/09\/parameter_names.png\" alt=\"\" class=\"wp-image-596733\"\/><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\">Errors and warnings<\/h2>\n\n\n\n<p>Sure, GoLand can point out compile errors \u2013 an angry red underline indicates the offending code, and you can hover the mouse over it to see what&#8217;s wrong (or use the Inspection Lens plugin to see all errors inline without hovering). Saved you a compile-edit-fix cycle.<\/p>\n\n\n\n<p>That&#8217;s great, but GoLand will also warn you about probable mistakes: unreachable code, unhandled errors, unused functions, redundant type conversions, or variable names that shadow the name of a package. Even though they&#8217;re technically legal (the best kind of legal), they&#8217;re likely not what you meant, and GoLand will pick these up and offer to auto-fix them.<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img decoding=\"async\" loading=\"lazy\" width=\"1598\" height=\"800\" src=\"https:\/\/blog.jetbrains.com\/wp-content\/uploads\/2025\/09\/errors_and_warnings.png\" alt=\"\" class=\"wp-image-596744\"\/><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\"><code>Nil<\/code> pointer analysis<\/h2>\n\n\n\n<p>Ah, pointers! The cause of \u2013 and solution to \u2013 all programming problems. Specifically, pointers can be <code>nil<\/code> (meaning \u201cdoesn&#8217;t point to any value\u201d). That&#8217;s a problem if you try to dereference such a pointer (that is, ask Go to give you the value it points to), and by \u201cproblem\u201d I mean \u201chorrible crash\u201d.<\/p>\n\n\n\n<p>But how can you tell whether a pointer will be <code>nil<\/code> at run time without running the program? Only by understanding the complete history of that variable throughout the code. Unfortunately, even GoLand isn&#8217;t yet smart enough to *<em>touches earpiece*<\/em> and I&#8217;m being told that in fact GoLand is now smart enough to do that.<\/p>\n\n\n\n<p>The experimental <a href=\"https:\/\/blog.jetbrains.com\/go\/2025\/07\/28\/interprocedural-analysis-catch-nil-dereferences-before-they-crash-your-code\/ ?\"><em>data flow analysis<\/em> feature<\/a> simulates the execution of your program to catch run-time errors like <code>nil<\/code> pointers even before you run it. That&#8217;s something I&#8217;ve never seen before in an IDE, and it&#8217;s pretty impressive.<\/p>\n\n\n\n<figure class=\"wp-block-gallery has-nested-images columns-default is-cropped wp-block-gallery-1 is-layout-flex wp-block-gallery-is-layout-flex\">\n<figure class=\"wp-block-image size-large\"><img decoding=\"async\" loading=\"lazy\" width=\"3200\" height=\"1620\" data-id=\"603133\" src=\"https:\/\/blog.jetbrains.com\/wp-content\/uploads\/2025\/09\/Screenshot-2025-09-13-at-17.30.08.png\" alt=\"\" class=\"wp-image-603133\"\/><\/figure>\n<\/figure>\n\n\n\n<h2 class=\"wp-block-heading\">Completions and templates<\/h2>\n\n\n\n<p>You&#8217;d expect GoLand to offer inline completions of function and variable names and so on, but that&#8217;s table stakes. Even more powerful are live templates: parameterized code snippets you can insert and complete interactively.<\/p>\n\n\n\n<p>For example, if you want to write a <code>for ... range<\/code> loop, type <code>for<\/code>, and select <em>For range loop<\/em> from the picklist (or type <code>forr<\/code> and press Tab). You&#8217;ll get a skeleton <code>for<\/code> loop with placeholders for you to fill in the loop variables and body.<\/p>\n\n\n\n<p>Similarly, if you get bored typing <code>if err != nil...<\/code> repeatedly (but how could anyone find that boring?) GoLand can fill in the error-handling block for you, if you ask nicely.<\/p>\n\n\n\n<p>Live templates automate dozens of the most common Go patterns and idioms, and you can create your own, with placeholders like <code>$INDEX$<\/code> for parameters you want users to fill in.<\/p>\n\n\n\n<p>Also, if you have a blob of JSON data that you need to turn into a Go type, just paste it into the editor. GoLand will offer to generate the struct definition for you automatically, complete with <code>json<\/code> tags to make it parseable.<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img decoding=\"async\" loading=\"lazy\" width=\"1600\" height=\"800\" src=\"https:\/\/blog.jetbrains.com\/wp-content\/uploads\/2025\/09\/completions_and_templates.gif\" alt=\"\" class=\"wp-image-596755\"\/><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\">Refactoring<\/h2>\n\n\n\n<p>Do you ever wish you&#8217;d named your child something different? It might be a bit late to revisit that one, but fortunately it&#8217;s always possible to rename things in your Go programs, like functions and variables.<\/p>\n\n\n\n<p>Manually retyping them everywhere would be annoying, and normal search-and-replace is error-prone (the <a href=\"https:\/\/en.wikipedia.org\/wiki\/Scunthorpe_problem\" target=\"_blank\" rel=\"noopener\">Scunthorpe<\/a> problem). GoLand is smarter about this because it understands Go: it knows if a word is a variable or function name, and avoids replacing it if it&#8217;s in some other context like inside a string or a comment.<\/p>\n\n\n\n<p>Also, you can edit a function&#8217;s signature, adding or removing parameters as you like, and GoLand will automatically change the calls to that function everywhere.<\/p>\n\n\n\n<p>Or try this one weird tip to slim down your chubby functions, and make your code beach body ready: select some lines and use <em>Extract method<\/em> to replace them with a call to a method that does the same thing. By eliminating paperwork, you make the program more readable and focus on what&#8217;s actually relevant.<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img decoding=\"async\" loading=\"lazy\" width=\"1600\" height=\"800\" src=\"https:\/\/blog.jetbrains.com\/wp-content\/uploads\/2025\/09\/refactoring_change_signature_01.png\" alt=\"\" class=\"wp-image-596766\"\/><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\">Debugging<\/h2>\n\n\n\n<p>Now, I&#8217;m not saying you ever write bugs \u2013 perish the thought. Shall we say rather that programs occasionally don&#8217;t behave exactly the way we expect them to? Figuring out just where and why things are going wrong can be difficult, unless you can shrink down to the size of an electron and go inside the computer to see what&#8217;s happening (I&#8217;m still waiting on that Kickstarter).<\/p>\n\n\n\n<p>Failing this, though, GoLand&#8217;s debugger is a pretty acceptable substitute. For example, set a breakpoint on a suspicious line and the debugger will stop the program there, keeping all variables intact so that you can inspect them (or edit them). Breakpoints can be conditional, too, so you only stop if a certain expression is true.<\/p>\n\n\n\n<p>Then, if the problem still isn&#8217;t clear, you can <em>Step Over<\/em> to continue executing the code line by line, or <em>Step Into<\/em> to follow function calls down the rabbit hole.<\/p>\n\n\n\n<p>To get really inside baseball, you can set a <em>watch<\/em> on the variables you&#8217;re interested in, or even arbitrary Go expressions, and see their values change as the program runs.<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img decoding=\"async\" loading=\"lazy\" width=\"1600\" height=\"792\" src=\"https:\/\/blog.jetbrains.com\/wp-content\/uploads\/2025\/09\/debugging.png\" alt=\"\" class=\"wp-image-596777\"\/><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\">JetBrains AI tools<\/h2>\n\n\n\n<p>You were expecting this, right? Everything has AI now (or as I like to say, \u201cEverything&#8217;s computer\u201d). GoLand&#8217;s optional <a href=\"https:\/\/plugins.jetbrains.com\/plugin\/22282-jetbrains-ai-assistant?utm_content=ai-button-link-click&amp;utm_medium=link&amp;utm_source=jetbrains.com\" target=\"_blank\" rel=\"noopener\">AI Assistant plugin<\/a> is there, not to supplant your wonderfully human intelligence, but to support it.<\/p>\n\n\n\n<p>For example, you can highlight some code and ask the assistant to explain it,&nbsp; suggest refactorings, or generate tests. You can ask it questions about the language or the standard library \u2013 all those \u201cat this point I&#8217;m afraid to ask\u201d things, and it won&#8217;t judge you.<\/p>\n\n\n\n<p>Naturally, you can also use <a href=\"https:\/\/plugins.jetbrains.com\/plugin\/26104-jetbrains-junie?utm_campaign=junie252&amp;utm_content=whatsnew&amp;utm_medium=in-product&amp;utm_source=goland\" target=\"_blank\" rel=\"noopener\">Junie<\/a>, the JetBrains AI coding agent, as part of GoLand. You can ask Junie to write whole packages or programs for you, or to read a bunch of user requirements and sketch out a system design, then implement it.<\/p>\n\n\n\n<p>If there&#8217;s some project you&#8217;ve always wanted to write, but you aren&#8217;t sure how to get started, collaborating with Junie could get you unblocked. Think of Junie as a pair programmer who doesn&#8217;t get bored or lose focus, and who can help you out with program structure and algorithms while still letting you have the fun of writing the interesting parts yourself.<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img decoding=\"async\" loading=\"lazy\" width=\"3840\" height=\"2160\" src=\"https:\/\/blog.jetbrains.com\/wp-content\/uploads\/2025\/09\/4-1.png\" alt=\"\" class=\"wp-image-596788\"\/><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\">There&#8217;s more<\/h2>\n\n\n\n<p>What&#8217;s that? Ten superpowers aren&#8217;t enough for you? You&#8217;ve got some attitude, mister. Look, GoLand can do more than we&#8217;ve had time to cover here \u2013 a <em>lot<\/em> more. But these ten things are a great place to start. Once you&#8217;ve mastered them, feel free to explore: read <a href=\"https:\/\/www.jetbrains.com\/help\/go\/getting-started.html\" target=\"_blank\" rel=\"noopener\">the docs<\/a>, click around, try stuff out.<\/p>\n\n\n\n<p>Don&#8217;t be like my non-copy-pasting friend, always too busy cutting wood to stop and sharpen the saw. A few minutes a day invested in really learning your IDE is time well spent. Pretty soon, these superpowers will become part of your muscle memory, just like copy and paste. (GoLand has that too. You&#8217;re welcome.)<\/p>\n","protected":false},"author":1386,"featured_media":597304,"comment_status":"closed","ping_status":"closed","template":"","categories":[808],"tags":[],"cross-post-tag":[],"acf":[],"_links":{"self":[{"href":"https:\/\/blog.jetbrains.com\/zh-hans\/wp-json\/wp\/v2\/go\/596699"}],"collection":[{"href":"https:\/\/blog.jetbrains.com\/zh-hans\/wp-json\/wp\/v2\/go"}],"about":[{"href":"https:\/\/blog.jetbrains.com\/zh-hans\/wp-json\/wp\/v2\/types\/go"}],"author":[{"embeddable":true,"href":"https:\/\/blog.jetbrains.com\/zh-hans\/wp-json\/wp\/v2\/users\/1386"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.jetbrains.com\/zh-hans\/wp-json\/wp\/v2\/comments?post=596699"}],"version-history":[{"count":10,"href":"https:\/\/blog.jetbrains.com\/zh-hans\/wp-json\/wp\/v2\/go\/596699\/revisions"}],"predecessor-version":[{"id":603144,"href":"https:\/\/blog.jetbrains.com\/zh-hans\/wp-json\/wp\/v2\/go\/596699\/revisions\/603144"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/blog.jetbrains.com\/zh-hans\/wp-json\/wp\/v2\/media\/597304"}],"wp:attachment":[{"href":"https:\/\/blog.jetbrains.com\/zh-hans\/wp-json\/wp\/v2\/media?parent=596699"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.jetbrains.com\/zh-hans\/wp-json\/wp\/v2\/categories?post=596699"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.jetbrains.com\/zh-hans\/wp-json\/wp\/v2\/tags?post=596699"},{"taxonomy":"cross-post-tag","embeddable":true,"href":"https:\/\/blog.jetbrains.com\/zh-hans\/wp-json\/wp\/v2\/cross-post-tag?post=596699"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}