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")
}Feedback
Was this page helpful?
Glad to hear it! Please tell us how we can improve.
Sorry to hear that. Please tell us how we can improve.