Yup, Go-style interfaces (looser than Java's, but more formal then Python's duck-typing) make wonders - allows code reuse among a lot of other things!
2019. január 27., vasárnap 21:08:45 UTC+1 időpontban Nuclear Squid!! a következőt írta: > > ...@Tamás Gulácsi <javascript:> > > I just wanted to thank you for your advice -- this works wonderfully. > > I am still surprised by how Go's type system and thoughtful stdlib design > allows clever ways to override and extend standard behaviours without a lot > of code and complexity! > > > > On Sat, 26 Jan 2019 at 00:46, Tamás Gulácsi <[email protected] > <javascript:>> wrote: > >> Something along the lines of https://play.golang.org/p/YgVIP_6uIWG can >> work. >> >> 2019. január 26., szombat 8:36:59 UTC+1 időpontban Tamás Gulácsi a >> következőt írta: >>> >>> dirList is just 20 lines of code, you can easily reimplement it with >>> your decorators. >>> >>> To ake this as an extension of ServeFile, you have to embed ServeFile >>> into your struct, and implement a ServeHTTP method which prints dirs as you >>> wish if the request is a GET of a directory, but call the embedded >>> ServeFile.ServeHTTP otherwise. >>> >> -- >> You received this message because you are subscribed to the Google Groups >> "golang-nuts" group. >> To unsubscribe from this group and stop receiving emails from it, send an >> email to [email protected] <javascript:>. >> For more options, visit https://groups.google.com/d/optout. >> > -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. For more options, visit https://groups.google.com/d/optout.
