Re: [go-nuts] Idiomatic Go code

2021-03-04 Thread 'Axel Wagner' via golang-nuts
On Thu, Mar 4, 2021 at 4:28 PM Christian von Kietzell < chris...@vonkietzell.de> wrote: > Side note about flushing: I'm flushing the wrapping > bufio.Writer there. I'd be surprised closing the underlying os.File would > be > enough to ensure all buffer contents have been written. > True, I didn't

Re: [go-nuts] Idiomatic Go code

2021-03-04 Thread Christian von Kietzell
Hi, thank you for the helpful comments. That's what I love about the Go community. On Thu, Mar 04, 2021 at 03:14:04PM +0100, 'Axel Wagner' via golang-nuts wrote: > - Who's responsible for doing that work? If I return *os.File directly > from getFile(), there's an implicit assumption that

Re: [go-nuts] Idiomatic Go code

2021-03-04 Thread 'Axel Wagner' via golang-nuts
I don't think it's inherently *un*idiomatic to return a cleanup function. But in this case, it seems unnecessarily complicated (and buggy). On Thu, Mar 4, 2021 at 2:19 PM Christian von Kietzell < chris...@vonkietzell.de> wrote: > - doSomething doesn't care whether the output is a file or a buffer

Re: [go-nuts] Idiomatic Go code

2021-03-04 Thread burak serdar
On Thu, Mar 4, 2021 at 6:19 AM Christian von Kietzell wrote: > > Hello Gophers, > > since I obviously don't have enough Twitter followers to get more than > one answer to my Go question I'm posting it here ;-) > > Would you consider this idiomatic Go code? > > https://play.golang.org/p/ymPt_9tKQ9p

[go-nuts] Idiomatic Go code

2021-03-04 Thread Christian von Kietzell
Hello Gophers, since I obviously don't have enough Twitter followers to get more than one answer to my Go question I'm posting it here ;-) Would you consider this idiomatic Go code? https://play.golang.org/p/ymPt_9tKQ9p I'm talking specifically about returning a cleanup function. My reasoni