Skip to content

Latest commit

 

History

History
47 lines (35 loc) · 1.09 KB

.godocdown.md

File metadata and controls

47 lines (35 loc) · 1.09 KB

goq

Build Status GoDoc Coverage Status Go Report Card

Example

import (
	"log"
	"net/http"

	"astuart.co/goq"
)

// Structured representation for github file name table
type example struct {
  Title string `goquery:"h1"`
  Files []string `goquery:"table.files tbody tr.js-navigation-item td.content,text"`
}

func main() {
  res, err := http.Get("https://github.com/andrewstuart/goq")
	if err != nil {
		log.Fatal(err)
	}
	defer res.Body.Close()

	var ex example
	
	err = goq.NewDecoder(res.Body).Decode(&ex)
	if err != nil {
		log.Fatal(err)
	}

	log.Println(ex.Title, ex.Files)
}

Details

{{ .Emit }}

TODO

  • Callable goquery methods with args, via reflection