# 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.
## Install
```
go get -u github.com/yosssi/gohtml
```
## 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.
```
## Output 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)