How to post code on this forum


(Johan Dahl) #1

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!


Cgo argument has Go pointer to Go pointer
CSS and JS doesn't work with Golang HTTP server
Using MAKE during slice creation
Module Init code reference undefined SOLVED
Gohtml : Changes not impacted after building
net.Listen tcp bind: The Requested address is not valid in its context
Help with api and basic http auth
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…


(system) closed #4

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