Re: [go-nuts] Simplest way to extend the functionality of other's package

2016-06-17 Thread Nigel Tao
On Thu, Jun 16, 2016 at 2:11 PM, Tong Sun wrote: > How to define my own function > > > func FindUrl() { return > goquery.Find(".thing").Find(".comments.may-blank").Attr("href"); } > > so that the above code can be simplified as: > > post_url, _ := doc.FindUrl() In your own package, you can only

[go-nuts] Simplest way to extend the functionality of other's package

2016-06-15 Thread Tong Sun
Let me explain with an example, For goquery, most functions are of type "func (s *Selection) Xxx(selector string) *Selection". For e.g., "Find" is: func (s *Selection ) Find(selector string ) *Select