From edd3bed070d53c0eee6a4924d410cad1e21595db Mon Sep 17 00:00:00 2001 From: Aidan Feldman Date: Fri, 27 May 2016 12:24:21 -0400 Subject: [PATCH] improve readme * Improved formatting * Added Mac installation instructions --- Readme.md | 55 ++++++++++++++++++++++++++++++++----------------------- 1 file changed, 32 insertions(+), 23 deletions(-) diff --git a/Readme.md b/Readme.md index bad8faf4..280a1a02 100644 --- a/Readme.md +++ b/Readme.md @@ -13,36 +13,45 @@ This is a major rewrite from v0 in the following places: - Serialization - Some API adjustment -To install: +## Installation -- sudo apt-get install libxml2-dev -- go get github.com/moovweb/gokogiri +```bash +# Linux +sudo apt-get install libxml2-dev +# Mac +brew install libxml2 -To run test: +go get github.com/moovweb/gokogiri +``` -- go test github.com/moovweb/gokogiri/html -- go test github.com/moovweb/gokogiri/xml +## Running tests -Basic example: +```bash +go test github.com/moovweb/gokogiri/... +``` - package main +## Basic example - import ( - "net/http" - "io/ioutil" - "github.com/moovweb/gokogiri" - ) +```go +package main - func main() { - // fetch and read a web page - resp, _ := http.Get("http://www.google.com") - page, _ := ioutil.ReadAll(resp.Body) +import ( + "net/http" + "io/ioutil" + "github.com/moovweb/gokogiri" +) - // parse the web page - doc, _ := gokogiri.ParseHtml(page) +func main() { + // fetch and read a web page + resp, _ := http.Get("http://www.google.com") + page, _ := ioutil.ReadAll(resp.Body) - // perform operations on the parsed page -- consult the tests for examples + // parse the web page + doc, _ := gokogiri.ParseHtml(page) - // important -- don't forget to free the resources when you're done! - doc.Free() - } \ No newline at end of file + // perform operations on the parsed page -- consult the tests for examples + + // important -- don't forget to free the resources when you're done! + doc.Free() +} +```