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] Optional params (RPC)

2016-07-22 Thread 'Mihai B' via golang-nuts
Is it idiomatic to use pointers on optional fields? I'm developing a RPC API and many resources have optional fields. For example AWS SDK[0] seems to use pointers for all the parameters (received and returned) including the struct fields. Is there any other way(i.e. best practice) to distingui

[go-nuts] [ANN] gitmap: map filenames to last commit-info

2016-07-22 Thread bep
I wrote this as part of a feature in Hugo, the static site generator, to use the last updated timestamp from the Git repo as the page modification date. But then I thought it might be interesting to others (and myself), so I pulled the code into its own repo. https://github.com/bep/gitmap A fa

Re: [go-nuts] Generation of Strings - generation

2016-07-22 Thread Tong Sun
Don't feel frustrated Michael. All the good advice from everyone here will benefit many more people besides OP. I myself learned a lot (especially, me too don't like the idea why channels has to be involved for such simple task initially, then saw that mind-opening comment from Paul Borman a

[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 he

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 via golang-nuts > w

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 Sync. WriteFile is a conv

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: https://godoc.org/fmt#hdr-Printing —Sam --

[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 gr

[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 "a

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 this cases would be [badly

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

2016-07-22 Thread Manlio Perillo
Il giorno giovedì 21 luglio 2016 22:01:52 UTC+2, Konstantin Khomoutov ha scritto: > > On Thu, 21 Jul 2016 21:17:38 +0200 > Manlio Perillo > wrote: > > > >> What is the reason why ioutil.WriteFile does not call File.Sync? > > > > > > I'd say that's because to inhibit this behaviour when needed

Re: [go-nuts] Re: Go 1.7 Release Candidate 3 is released

2016-07-22 Thread Steven Hartland
Thanks Chris appreciated :) On 22/07/2016 02:47, Chris Broadfoot wrote: A couple people requested a changelog between release candidates. I'll try to remember to include that for the 1.8 release candidates (we don't plan to do a 1.7rc4). GitHub has a nice view for commits between refs. Here'