# 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
[](https://app.wercker.com/project/bykey/926cf3edc004271539be40d705d037bd)
[](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.`
fmt.Println(gohtml.Format(h))
}
```
Output:
```html
This is a title.
```
## 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.`
fmt.Println(gohtml.FormatWithLineNo(h))
}
```
Output:
```sh
1
2
3
4
5 This is a title.
6
7
13
20
21
22
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)