Syntax Highlight for Go language
-
I’m trying to post source code in Go language, but it doesn’t seem to work. According to this: https://en.support.wordpress.com/code/posting-source-code/, the syntax highlight plugin supports Go, but I can’t make it work. Here’s the code:
[code language='go']
func main() {
fmt.Println('hello')
}
[/code]If I change the language to something else, it works.
The blog I need help with is: (visible only to logged in users)
-
Hi @guilhermegarnier, hope your having fun with your blog! I tried out your code and this is what I got:

Is this also what you are seeing? It seems that the highlighting for Go is just a slightly bigger font size. I haven’t tested it but if you are using a larger font size and same typeface on your blog then the “highlighting” may not even be noticeable.
Notice that PHP and CSS will get little boxes but Go just changes the typeface and size in the image above.
-
Hi guilhermegarnier,
I noticed the language name is between apostrophes (
'go') in your example but our documentation uses quote marks ("go").I’ve tested the code you provided and it is added to the page I used for testing but it isn’t styled in the same way as other languages like CSS. Your code is formatted in this style for me:
https://cloudup.com/cpg-YTe6WWP
Is this also what you are seeing? If not and you are unable to add the code at all, can you send a link to the post or page you are having trouble with?
-
Great catch @gemmacevans! I totally missed the double/single quote issue.
@guilhermegarnier, from my testing it seems that the shortcode will work with single or double quotes. Just be mindful that as pointed out the documentation does state the use of double quotes. This may just be a standardization for the documentation but important to keep in mind nonetheless. -
Hello @gemmacevans. I did use double quotes, but when I pasted the code here, it was replaced by single quotes.
What I see in my blog post is the code without any formatting. Here is an example: https://globodev.wordpress.com/2018/08/03/post-teste/
-
Hi guilhermegarnier,
Thanks for the post link, that’s a great help. I’m double checking on what the correct formatting should be for Go and I’ll come back to you when I know more.
-
Hi guilhermegarnier,
I’ve been looking into this and have some more information for you. While Go can be added between
[code]tags, syntax highlighting isn't currently supported for this language. I've updated our support documentation to reflect this so it doesn't cause any confusion — sorry about that!I'm going to put this forward as an enhancement idea but in the meantime, you may be able to achieve what you need by embedding a GIST instead.
Thanks for reporting this!
-
OK, thanks for the quick answer. I’m looking forward to have Go code supported!
BTW, I think you broke something when you updated the documentation. The example of usage (“To accomplish the above, just wrap your code in these tags”) is being rendered by syntax highlight itself.
-
- The topic ‘Syntax Highlight for Go language’ is closed to new replies.