text that you indent inside a comment, godoc will render as a pre-formatted block

jabielecki 2020-01-17 12:04:48 +01:00
parent f5ada43e72
commit 5b344398b7

@ -20,4 +20,19 @@ Nearly every top-level type, const, var and func should have a comment. A commen
func enterOrbit() os.Error {
...
}
```
```
All text that you indent inside a comment, godoc will render as a pre-formatted block. This facilitates code samples.
```go
// fight can be used on any enemy and returns whether Superman won.
//
// Examples:
//
// fight("a random potato")
// fight(LexLuthor{})
//
func fight(enemy interface{}) bool {
...
}
```