How to post code on this forum

Hi

Then posting code on this forum it is very good to do it in one of these ways:

  1. As a link till Go Playground https://play.golang.org Type in your code or paste it. Press the Format button to get it nicely formatted. Then press Share and you see a link which you can copy and paste in this forum.

  2. Or you can write or paste code here in the forum between two lines ```go and ``` (three backticks). Like this:

```go
a := b + c
Fmt.Println(“Answer is”, a)
```

and it will show up nicely formatted and syntax colored like this:

a := b + c
Fmt.Println("Answer is", a)

Keep up the good work!

2 Likes

I use two other methods to add code to posts. These won’t add syntax highlighting, but they are quick and easy.

Both of these require an empty line before and after the code.

First method: If the code is more than one line long, select the code and click on the </> button in the editor toolbar.

Second method: If the code is just one line, add four or more spaces before it. (This works with more than one line of code, but then it’s easier to use ``` or the </> button.)

1 Like

It would be quite nice if the forum could be extended with a button for go code…

1 Like

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.