Re: [go-nuts] golint if/else stmt and early returns

2017-03-16 Thread Nigel Tao
This is tangential, but if we're talking about style, you might be able to simplify this line ret = PropertiesList(ret).Append(PropertiesList(temp)) to be ret = PropertiesList(ret).Append(temp) if the PropertiesList underlying type and the temp variable's type are what I'm guessing they are:

Re: [go-nuts] Re: uint type safety in go

2017-03-16 Thread Nigel Tao
On Fri, Mar 17, 2017 at 5:02 AM, 'simon place' via golang-nuts wrote: > uint - uint = int Well, if the first uint is maxUint and the second uint is minUint (i.e. zero), then the difference between them will overflow an int. -- You received this message because you

Re: [go-nuts] Re: Go - language of the future!

2017-03-16 Thread Jesper Louis Andersen
I think this is too premature to make this call. Javascript is a language with no type system and it is relying a lot on runtime behavior. Yet, it was a "language of the future" when it was created and I don't think it was envisioned to become as big as it got. Attempts are replacing it are going

[go-nuts] Re: Go - language of the future!

2017-03-16 Thread prades . marq
A language with such a "simple" type system, which rely that much on runtime behavior is hardly a language of the future. But Go might be a blue print for what language of the futures will have to provide in terms of developer experience. Go is too divisive to get widely adopted or to replace

[go-nuts] Re: Go - language of the future!

2017-03-16 Thread mhhcbon
Did not need such analysis to claim such assertion, A language that does not bloat its users with semi colon (one for you https://groups.google.com/forum/#!topic/golang-nuts/rzLzp_Z74ik%5B1-25%5D), parenthesis where useless, with automatic formatting, tries to solve "les querelles de clocher",

Re: [go-nuts] golint if/else stmt and early returns

2017-03-16 Thread mhhcbon
yeah, i did write it like it before, but i want stop to shadow my variables as much as possible, i found mistakes happens too easily with that writing. On Thursday, March 16, 2017 at 7:28:17 PM UTC+1, rog wrote: > > I'd be inclined to write it something like this: > >

Re: [go-nuts] golint if/else stmt and early returns

2017-03-16 Thread mhhcbon
I d like to, but when I write, // Load returns the list of partition found and their properties. func (l *LinuxLoader) Load() ([]*Properties, error) { //- ret := []*Properties{} if temp, err := runDf(); err != nil { return ret, err } ret =

[go-nuts] Re: cgo using c struct array and assign value in go

2017-03-16 Thread Wei Zhang
Missing a C function void initializeProfile(_profile *profile, bool create) { if (create == true) { profile->dateOfBirth = NULL; } profile->profileId = 0; memset(profile->userName.first, '\0', sizeof(profile->userName.first)); : memset(profile->userName.last, '\0',

[go-nuts] Re: uint type safety in go

2017-03-16 Thread 'simon place' via golang-nuts
this sort of thing came up for me recently, in that i was thinking nicer built-in's would operate like this; float32 * float32 = float64 so also uint - uint = int in a way, type safety (native type isolation) is kind of causing an issue, and that maybe always using big (long) numbers during

Re: [go-nuts] golint if/else stmt and early returns

2017-03-16 Thread Paweł Kopiczko
Early returns are fine. You don't need all those else blocks. // Load returns the list of partition found and their properties. func (l *LinuxLoader) Load() ([]*Properties, error) { //- ret := []*Properties{} if temp, err := runDf(); err != nil { return ret, err } ret

[go-nuts] cgo using c struct array and assign value in go

2017-03-16 Thread wellszhane
I have issue when using cgo with c struct array. My program as follow: I have struct in c and contain a pointer to a c struct array. In C, I provide a initialize function (take two parameter: the pointer to the variable, the length of the array inside the variable) to malloc the memory of

Re: [go-nuts] golint if/else stmt and early returns

2017-03-16 Thread Ian Davis
It's saying you don't need the else clauses since you have returned in the if clause. On Thu, 16 Mar 2017, at 05:11 PM, mhhc...@gmail.com wrote: > Hi, > > golint will report > > if block ends with a return statement, so drop this else and outdent > its block (move short variable

[go-nuts] golint if/else stmt and early returns

2017-03-16 Thread mhhcbon
Hi, golint will report if block ends with a return statement, so drop this else and outdent its block (move short variable declaration to its own line if necessary) (golint) for this code, // Load returns the list of partition found and their properties. func (l *LinuxLoader) Load()

[go-nuts] Linking problems on Visual Studio 2015

2017-03-16 Thread Robert Bielik
Hi all, I have a project where I want to use grpc-gateway (written in Go) to expose a gRPC endpoint via REST. I've managed to get it to work with gateway parts compiled with Go into a separate executable, however, I would really like to package the gateway into the same library as the gRPC

Re: [go-nuts] uint type safety in go

2017-03-16 Thread peterGo
Michael, "Now, for personal opinion, I would share a tremendous frustration that programmers often don't think at all about these issues and thereby allow their thinking to be shallow. My clearest example is code like "k=i+j" or "k = i*j" both of which are common." Are you shocked—shocked—to

[go-nuts] Go - language of the future!

2017-03-16 Thread Art Mellor
Interesting/fun article where Erik Bernhardsson analyzes data about moving from one programming language to another https://erikbern.com/2017/03/15/the-eigenvector-of-why-we-moved-from-language-x-to-language-y.html -- You received this message because you are subscribed to the Google Groups

Re: [go-nuts] Re: How do I test an func which depends on (pseudo)-random numbers, e.g. rand.Intn()?

2017-03-16 Thread Simon Ritchie
As some posters have already said, it depends what you are trying to test. If you want to test what your solution does when it receives a randomly-generated number, then you don't need to use random numbers. You can hide the generation of the random number in a type which is defined by an

Re: [go-nuts] Re: Is there functionality in golang.org/x/crypto/ssh to close a SSH connection server-side after N number of (password) tries?

2017-03-16 Thread Konstantin Khomoutov
On Thu, 16 Mar 2017 03:07:44 -0700 (PDT) ikkini wrote: > For anyone trying this: If you 'break userAuthLoop, you'll end up > below the label, which equals success. Probably not what you want :/ > instead, I'm now using 'break' and authErr, which gives me the > desired behavior.

[go-nuts] Re: Is there functionality in golang.org/x/crypto/ssh to close a SSH connection server-side after N number of (password) tries?

2017-03-16 Thread ikkini
For anyone trying this: If you 'break userAuthLoop, you'll end up below the label, which equals success. Probably not what you want :/ instead, I'm now using 'break' and authErr, which gives me the desired behavior. diff --git a/ssh/server.go b/ssh/server.go index 37df1b3..0f4dd74 100644 ---

Re: [go-nuts] uint type safety in go

2017-03-16 Thread Michael Jones
Yes, there are cases for integer domain wraparound just as there are cases for exception at the limits. The argument FOR is that "computers work that way." Since ENIAC, there have been overflow condition flags, but there have rarely been overflow/underflow panic traps. (Either no support, or

Re: [go-nuts] uint type safety in go

2017-03-16 Thread roger peppe
On 14 March 2017 at 08:48, Eyal Posener wrote: > I was thinking about the type safety of uint in go, and comparing it for a > similar problem. > > If I have this go code: > > var x uint > x-- > > The value of x is then the maximal value of uint, which is probably not what > the

[go-nuts] Re: Need suggestion for bad code of reflection (using FieldByNameFunc and FieldByName inside it)

2017-03-16 Thread nvcnvn
Hi Ingo, > > v.FieldByNameFunc(func(fieldName string) bool { > field, _ := v.FieldByName(fieldName) > name := field.Tag,Get("name") > if len(name) == 0 { > name = fieldName > } > // > return false > }) Sorry for my bab explain. So tag name is more priority for me then I need to check if a field

[go-nuts] Re: Error checking and defer

2017-03-16 Thread Nathan Kerr
I prefer to accept that multiple errors can occur. https://pocketgophers.com/handling-errors-in-defer/ -- 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

[go-nuts] Need suggestion for bad code of reflection (using FieldByNameFunc and FieldByName inside it)

2017-03-16 Thread 'Ingo Oeser' via golang-nuts
What checks are you doing on struct field names and tags? That will be crucial to answering your question. -- 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

Re: [go-nuts] Re: How do I test an func which depends on (pseudo)-random numbers, e.g. rand.Intn()?

2017-03-16 Thread Michael Jones
You could also capture a (p)random stream as a test data vector and use it in lieu of the PRNG during tests. This is the same as seeding iff and only iff the PRNG is never changed, Should that change, then so will the tests unless you capture a test vector now. (For example, if you have a timing

[go-nuts] Need suggestion for bad code of reflection (using FieldByNameFunc and FieldByName inside it)

2017-03-16 Thread nvcnvn
I need to check all the field names and the tags of a struct, currently I do: > v.FieldByNameFunc(func(fieldName string) bool { > field, _ := v.FieldByName(fieldName) > // then do some work with field.Name and field.Tag > return false > }) I use *FieldByNameFunc* because it is an easy way

Re: [go-nuts] Re: Conserving memory in TLS handshake and x509 certificate verification

2017-03-16 Thread Dave Cheney
I don't think cgo is to blame then, the only cgo used by the http package is your system's DNS resolver. -- 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