How to post code on this forum

(Johan Dahl) #1


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 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 to lines ```go and ``` (three backticks). Like this:

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!

CSS and JS doesn't work with Golang HTTP server
Scope of variables in a program
(Jay Ts) #2

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.)

(Johan Dahl) #3

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