Re: [go-nuts] [ANN] reverse proxy with ssl in less than 100 lines of code

2018-01-03 Thread Peter Waller
On 28 December 2017 at 16:54, jzs wrote: > > Any feedback is more than welcome > Looks nice. A few minor ideas: There is code which appears after log.Fatal() - that code won't run because log.Fatal calls exit. Therefore the the waitgroup could be dropped and you'd have something shorter and stil

Re: [go-nuts] Extending an existing type by embedding

2018-01-03 Thread matthewjuran
> > 1. extend the `html.Tokenizer` with new methods of my own > 2. while still able to access all existing html.Tokenizer methods in the > mean time You have this by struct embedding: z := MyTokenizer1{html.NewTokenizer(r)} // don’t take the address, a pointer to a struct of pointers doesn’t

Re: [go-nuts] Extending an existing type by embedding

2018-01-03 Thread Tong Sun
On Wed, Jan 3, 2018 at 9:07 AM, wrote: > >> Why do you need varying types if you are just using html.Tokenizer > methods? What is the difference between each type? > The difference is the VisitToken(), using the same function of `WalkBody()`, but achieving different results. For example, the c

Re: [go-nuts] Extending an existing type by embedding

2018-01-03 Thread matthewjuran
Ah, this kind of function signature may be better: func WalkBody(t *html.Tokenizer, w TokenVisitor) { Then you would use the regular *html.Tokenizer methods to do the walk and pass each token to the TokenVisitor to be parsed for output depending on which TokenVisitor was picked. Matt On Wedne

[go-nuts] [ANN] Grumble - A powerful modern CLI and SHELL

2018-01-03 Thread roland . singer
There are a handful of powerful go CLI libraries available (spf13/cobra , urfave/cli ). However sometimes an integrated shell interface is a great and useful extension for the actual application. This library offers a simple API to

Re: [go-nuts] Extending an existing type by embedding

2018-01-03 Thread Tong Sun
Thanks Matt -- I thought it wouldn't work, but having thinking it over, and over, now I finally make it working. Thanks a lot On Wed, Jan 3, 2018 at 9:46 AM, wrote: > Ah, this kind of function signature may be better: > > func WalkBody(t *html.Tokenizer, w TokenVisitor) { > > Then you would use