This public service announcement (PSA) outlines some useful practices when asking for help. Many members are enthusiastic about helping Gophers, both beginner and experienced. Following these points makes it easier for us to help you and more likely you’ll get a prompt, useful answer.
Keywords are highlighted to make it easier to refer to specific points.
- Post quoted code by enclosing code blocks in triple-backticks ``` :
func add(x, y int) int {
return x + y
}
This will highlight syntax and use a monospace font. Don’t post your code as a screenshot ; it is difficult to read and impossible to copy-paste. Consider using the Go Playground to share code snippets.
-
Indent and format your code to reflect its structure (using the go fmt tool should help with this). Indented code is easier to understand and troubleshoot.
-
Do your best to make your example self-contained (“minimal working example”, MWE ), so that it runs (or gets to the error that you want help with) as is. This means including package loading (e.g.
import "thepackage"
) and any data that the code operates on. If your data is large or proprietary, generate example data if possible and include that. -
Simplify your code to the smallest piece of code that still shows your problem. This step takes the most effort but is the most important for fixing your problem. Short, simple examples tend to get answers quickly.
-
Include all errror messages. They often contain valuable information, even if they seem cryptic. Please quote the error messages as well (see point 1).
-
You may not get a response here for packages with a very narrow audience. In that case, you may want to consider opening an issue on Github (or Gitlab, etc) for the package repository, just to ask a question. Most packages are OK with this.
-
If an answer solves your problem, mark it as solved by clicking the “ Solution” button. This makes it easier for future help-seekers to find the correct answer, especially in a long discussion.
This post has been adapted with permission from the Julia Programming Discourse.