# gohtml **Repository Path**: mirrors_anthonyfok/gohtml ## Basic Information - **Project Name**: gohtml - **Description**: HTML formatter for Go - **Primary Language**: Unknown - **License**: MIT - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2020-09-24 - **Last Updated**: 2026-10-10 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # GoHTML - HTML formatter for Go [![wercker status](https://app.wercker.com/status/926cf3edc004271539be40d705d037bd/s "wercker status")](https://app.wercker.com/project/bykey/926cf3edc004271539be40d705d037bd) [![GoDoc](http://godoc.org/github.com/yosssi/gohtml?status.png)](http://godoc.org/github.com/yosssi/gohtml) GoHTML is an HTML formatter for [Go](http://golang.org/). You can format HTML source codes by using this package. ## Example Example Go source code: ```go package main import ( "fmt" "github.com/yosssi/gohtml" ) func main() { h := `This is a title.

AAA
BBB>

` fmt.Println(gohtml.Format(h)) } ``` Output: ```html This is a title.

AAA
BBB>

``` ## Ouput Formatted HTML with Line No You can output formatted HTML source codes with line no by calling `FormatWithLineNo`: ```go package main import ( "fmt" "github.com/yosssi/gohtml" ) func main() { h := `This is a title.

AAA
BBB>

` fmt.Println(gohtml.FormatWithLineNo(h)) } ``` Output: ```sh 1 2 3 4 5 This is a title. 6 7 13 20 21 22
23 24

25 AAA 26
27 BBB> 28

29
30 31 32 ``` ## Format Go html/template Package's Template's Execute Result You can format [Go html/template package](http://golang.org/pkg/html/template/)'s template's execute result by passing `Writer` to the `tpl.Execute`: ```go package main import ( "os" "text/template" "github.com/yosssi/gohtml" ) func main() { tpl, err := template.New("test").Parse("{{.Msg}}") if err != nil { panic(err) } data := map[string]interface{}{"Msg": "Hello!"} err = tpl.Execute(gohtml.NewWriter(os.Stdout), data) if err != nil { panic(err) } } ``` Output: ```html Hello! ``` ## Docs * [GoDoc](https://godoc.org/github.com/yosssi/gohtml)