Re: [go-nuts] ioutil.WriteFile and Sync

2016-07-22 Thread Richard Boyer
I made a simple library for personal use awhile ago ( https://github.com/rboyer/safeio) that tries to sequence posix atomic operations and fsync operations on file and directories for those times when you just need: 1. create temp file 2. write to temp file 3. fsync and close temp file

[go-nuts] [ANN] Legit Input Validation

2016-07-22 Thread James Cunningham
Hey Gophers! Today I released my library to help with user input validation, called Legit. I would appreciate any and all feedback. The difference between existing libraries which tend to use struct tags, Legit defines an interface requiring types have a method called `Validate` and exposes

Re: [go-nuts] Is there a way to implement this C macro in Go?

2016-07-22 Thread Matt Harden
No, there's no way to do that in Go. There is no preprocessor nor any other way to obtain the original expression. You'll have to duplicate the expression as part of your format string. On Fri, Jul 22, 2016 at 6:57 AM Sam Whited wrote: > On Thu, Jul 21, 2016 at 7:09 PM, sque

Re: [go-nuts] ioutil.WriteFile and Sync

2016-07-22 Thread Ian Lance Taylor
On Fri, Jul 22, 2016 at 3:40 AM, Manlio Perillo wrote: > > I think your reasoning is wrong. > WriteFile is a "self contained" function; it does not return the handle to > the file, so it can not be used inside a transaction. > I really don't see valid reasons to not call

Re: [go-nuts] Is there a way to implement this C macro in Go?

2016-07-22 Thread Sam Whited
On Thu, Jul 21, 2016 at 7:09 PM, sque via golang-nuts wrote: > The "#x" is the really useful part that lets you print the original > expression. For example, if int a = 4 and int b = 10 This is not exactly the same, but %#v is probably what you want:

[go-nuts] [ANN] bench

2016-07-22 Thread Jan Mercl
>From the today-I-needed department: Bench[0] is a tool for running package benchmarks in isolation, one by one. [0]: https://godoc.org/github.com/cznic/bench -- -j -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this

[go-nuts] Is there a way to implement this C macro in Go?

2016-07-22 Thread sque via golang-nuts
I've used this macro or some variant thereof in C/C++ for years: #define dump(x) printf("%s %d: %s = %d\n", __func__, __LINE__, #x, (int)(x)) The "#x" is the really useful part that lets you print the original expression. For example, if int a = 4 and int b = 10: dump(a + b); // Prints

Re: [go-nuts] ioutil.WriteFile and Sync

2016-07-22 Thread Jan Mercl
On Fri, Jul 22, 2016 at 12:40 PM Manlio Perillo wrote: > I really don't see valid reasons to not call Sync. There are valid use cases where WriteFile produces a transitive file with no requirements whatsoever to reach any storage above the kernel caches. Performance in