Skip to content

Instantly share code, notes, and snippets.

@vaskoz
Created March 4, 2014 00:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save vaskoz/9337472 to your computer and use it in GitHub Desktop.
Save vaskoz/9337472 to your computer and use it in GitHub Desktop.
Simple Gokogiri example file that reads and writes the file.
package main
import (
g "github.com/moovweb/gokogiri"
. "io/ioutil"
_ "fmt"
"os"
)
func main() {
file, err := ReadFile("/Users/vaskozdravevski/tmp/data.html")
if err != nil {
panic("Can't load the file")
}
htmlDoc, err := g.ParseHtml(file)
if err != nil {
panic("Can't parse HTML")
}
WriteFile("/Users/vaskozdravevski/tmp/output.html",
[]byte(htmlDoc.String()), os.FileMode(0666))
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment