Snippet

block style

package main

import "fmt"

func main() {
    fmt.Println("hello world")
}

Using option {linenos=inline hl_lines=[3,"6-8"] style=emacs}.

See https://gohugo.io/content-management/syntax-highlighting/

1package main
2
3import "fmt"
4
5func main() {
6    for i := 0; i < 3; i++ {
7        fmt.Println("Value of i:", i)
8    }
9}

import from file

code lang="go" opts="" source="main.go"

package main

import "fmt"

func main() {
	fmt.Println("hello world")
}

import from file with line range

snippet lang="go" opts="" source="hello.go" from="5" to="7"

func hello() {
	fmt.Println("hello world")
}

import from file with tag

snippet-tag lang="go" opts="" source="foobar.go" tag="foo"

func foo() {
	fmt.Println("hello foo")
}

snippet-tag lang="go" opts="" source="foobar.go" tag="bar"

func bar() {
	fmt.Println("hello bar")
}

Last modified December 31, 2025: update code (5dc96f6)