[go-nuts] Re: built-in alternative to bcrypt?

2019-04-24 Thread Henry
Hello, If you want to store passwords, then bcrypt , scrypt , and argon2 are commonly used. They are available in Go's extended library. SHA is a

Re: [go-nuts] Go if else syntax .. suggested replacement

2019-04-24 Thread Reto
On Wed, Apr 24, 2019 at 04:24:41PM -0500, Andrew Klager wrote: > Is this so bad? Yes, it's horrible as you'll loose any type information you had. Meaning the next thing you naturally had to do was type cast it, which isn't the nicest syntax to begin with. By then it's probably more work than

Re: [go-nuts] Re: Go if else syntax .. suggested replacement

2019-04-24 Thread Matt Harden
On Wed, Apr 24, 2019 at 8:42 PM David Koblas wrote: > IMHO I've wanted a switch expression, rather than a switch statement for a > while. > I've wanted that too, but what we already have really isn't that bad. > value := switch test { > case true => "red" > case false => "blue" > } > >

Re: [go-nuts] Re: Go if else syntax .. suggested replacement

2019-04-24 Thread David Koblas
IMHO I've wanted a switch expression, rather than a switch statement for a while. value := switch test { case true => "red" case false => "blue" } or value := switch item.(type) { case int => item case string => strconv.Atoi(item) case time.Time => {     ... something more involved

Re: [go-nuts] Go if else syntax .. suggested replacement

2019-04-24 Thread andrey mirtchovski
Please do! We need to resolve this connundrum for the next 5 generations of computer programmers! On Wed, Apr 24, 2019 at 8:41 PM David Riley wrote: > > On Apr 24, 2019, at 5:25 PM, andrey mirtchovski wrote: > > > >> I may easily misremember, but that doesn't match my recollection. I > >>

Re: [go-nuts] Go if else syntax .. suggested replacement

2019-04-24 Thread David Riley
On Apr 24, 2019, at 5:25 PM, andrey mirtchovski wrote: > >> I may easily misremember, but that doesn't match my recollection. I >> don't remember what position Rob and Robert took, but as I recall Ken >> was generally opposed to the ternary operator. He had been in part >> responsible for

Re: [go-nuts] Re: Go if else syntax .. suggested replacement

2019-04-24 Thread Robert Engels
Wow that was some bad typing + bad auto correct... > On Apr 24, 2019, at 9:15 PM, Robert Engels wrote: > > Your original proposal did not have the colon and also implied the {} were > mandatory. And what stops the sane syntax from. Ring nested ? > >> On Apr 24, 2019, at 6:28 PM,

Re: [go-nuts] Re: Go if else syntax .. suggested replacement

2019-04-24 Thread Robert Engels
Your original proposal did not have the colon and also implied the {} were mandatory. And what stops the sane syntax from. Ring nested ? > On Apr 24, 2019, at 6:28 PM, lgod...@gmail.com wrote: > > Just to clarify : My original proposal was to include as part of Go the > syntax > > (test) ?

Re: [go-nuts] Re: Go if else syntax .. suggested replacement

2019-04-24 Thread Dan Kortschak
I don't think that's an answer to my comment. Was it intended to be? lgodio wrote that they wanted ternary operators, but were not advocating that it be possible to allow nested ternary operations. I don't see how this is possible if you write the grammar as the only sensible interpretation

Re: [go-nuts] Re: Go if else syntax .. suggested replacement

2019-04-24 Thread Michael Jones
switch test { case true: //..code block for test=true case false: //..code block for test=false } On Wed, Apr 24, 2019 at 4:42 PM Dan Kortschak wrote: > How would you preclude it? > > On Wed, 2019-04-24 at 16:28 -0700, lgod...@gmail.com wrote: > > I am NOT in favor of allowing nested

Re: [go-nuts] Re: Go if else syntax .. suggested replacement

2019-04-24 Thread Dan Kortschak
How would you preclude it? On Wed, 2019-04-24 at 16:28 -0700, lgod...@gmail.com wrote: > I am NOT in favor of allowing nested ternary operations -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receiving

[go-nuts] Re: Go if else syntax .. suggested replacement

2019-04-24 Thread lgodio2
Just to clarify : My original proposal was to include as part of Go the syntax (test) ? { { //..code block for test=true } : { //..code block for test=false } I am NOT in favor of allowing nested ternary operations In addition, I also propose allowing un-nested '?' as an alternative

Re: [go-nuts] Go if else syntax .. suggested replacement

2019-04-24 Thread Mark Volkmann
Nested ternaries are fairly readable in JavaScript these days due to the use of Prettier for code formatting. gofmt could do the same. For example, this: lc_unicodeliterals = quote=='u' ? 1 : quote=='U' ? 0 : !!(ast.locale.set & AST_LC_unicodeliterals); could be formatted to this:

Re: [go-nuts] Go if else syntax .. suggested replacement

2019-04-24 Thread lgodio2
For me, choosing to write color = temp < 80 ? { "blue", "red") vs func ternary(cond bool, pos, neg interface{}) interface{} { if cond { return pos } else { return neg } } color := ternary( temp < 80, "blue", "red") is a no brainer On Wednesday, April 24, 2019 at 5:25:09 PM

Re: [go-nuts] Go if else syntax .. suggested replacement

2019-04-24 Thread lgodio2
If instead of writing: temperature > 80 ? red : green you choose to follow Marcus and write instead: map[bool]string{true:"red",false:"green"}[temperature>80] OR call func ternary(x int) int { return map[bool]int{true:12345,false:-1}[x>0] } Go right ahead ! ..as they say, "different

Re: [go-nuts] Go+ replacement

2019-04-24 Thread Ronny Bangsund
I occasionally read this list, and sometimes I stop by the Go Slack. There are many channels there, and the general one might actually be the least interesting to many. I mostly follow the VSCode discussions/live help channel, and sometimes there's activity in other project-specific or

Re: [go-nuts] Go if else syntax .. suggested replacement

2019-04-24 Thread andrey mirtchovski
> I may easily misremember, but that doesn't match my recollection. I > don't remember what position Rob and Robert took, but as I recall Ken > was generally opposed to the ternary operator. He had been in part > responsible for adding it to C, and felt that it had been a mistake. > > Ian I am

Re: [go-nuts] Go if else syntax .. suggested replacement

2019-04-24 Thread Andrew Klager
Is this so bad? func ternary(cond bool, pos, neg interface{}) interface{} { if cond { return pos } else { return neg } } color := ternary( temp < 80, "blue", "red") On Wed, Apr 24, 2019 at 4:14 PM Chris Broadfoot wrote: > > > On Wed, Apr 24, 2019 at 4:22 AM Robert Engels > wrote: >

Re: [go-nuts] Go if else syntax .. suggested replacement

2019-04-24 Thread Chris Broadfoot
On Wed, Apr 24, 2019 at 4:22 AM Robert Engels wrote: > Though to the ops point, not sure why Go doesn’t have the ternary operator > - which is pretty ubiquitous. > https://golang.org/doc/faq#Does_Go_have_a_ternary_form > > On Apr 23, 2019, at 9:56 PM, Robert Engels wrote: > > Why? You have

Re: [go-nuts] Go if else syntax .. suggested replacement

2019-04-24 Thread David Riley
On Apr 24, 2019, at 12:34 PM, Marcus Low wrote: > > On Wednesday, April 24, 2019 at 10:08:53 PM UTC+8, Mark Volkmann wrote: >> Are there really developers that find this unreadable? >> >> color := temperature > 80 ? “red” : “green” >> >> I know what you are going to say. People will nest

Re: [go-nuts] Go if else syntax .. suggested replacement

2019-04-24 Thread David Riley
On Apr 24, 2019, at 8:04 AM, Mark Volkmann wrote: > > >> On Apr 24, 2019, at 6:22 AM, Robert Engels wrote: >> >> Though to the ops point, not sure why Go doesn’t have the ternary operator - >> which is pretty ubiquitous. > > The idea of adding the ternary operator to Go has been debated

Re: [go-nuts] Go if else syntax .. suggested replacement

2019-04-24 Thread Ian Lance Taylor
On Wed, Apr 24, 2019 at 1:14 PM andrey mirtchovski wrote: > > Here's the lore associated with the subject: Ken wanted ternary, Rob > and Robert did not. They overruled Ken (remember, early on all three > had to agree for a feature to go in). The end. I may easily misremember, but that doesn't

Re: [go-nuts] Go if else syntax .. suggested replacement

2019-04-24 Thread Kurtis Rader
On Wed, Apr 24, 2019 at 1:14 PM andrey mirtchovski wrote: > Here's the lore associated with the subject: Ken wanted ternary, Rob > and Robert did not. They overruled Ken (remember, early on all three > had to agree for a feature to go in). The end. > > The number of frivolous and egregious abuse

Re: [go-nuts] Go if else syntax .. suggested replacement

2019-04-24 Thread andrey mirtchovski
Here's the lore associated with the subject: Ken wanted ternary, Rob and Robert did not. They overruled Ken (remember, early on all three had to agree for a feature to go in). The end. The number of frivolous and egregious abuse of ternary that I've seen in _modern_ C code is too high.jpg --

Re: [go-nuts] Go if else syntax .. suggested replacement

2019-04-24 Thread Robert Engels
I agree, and I think the ternary represents the logic much cleaner than if/else in this case. This would be especially true if you could do: final datalen := value==nil ? removedKeyken : len(value) > On Apr 24, 2019, at 1:18 PM, Mark Volkmann wrote: > > I'm at a loss as to how that could be

Re: [go-nuts] Go if else syntax .. suggested replacement

2019-04-24 Thread Mark Volkmann
I'm at a loss as to how that could be considered more readable that a single ternary. You've successfully changed five lines to four lines, but that's still a long way from one line. On Wed, Apr 24, 2019 at 12:15 PM Marcus Low wrote: > Yeah of course I was joking... the solution I provided does

Re: [go-nuts] Go if else syntax .. suggested replacement

2019-04-24 Thread Marcus Low
Yeah of course I was joking... the solution I provided does work for the "I need a one-liner" mentality, though. I believe this following solution fits your use case, and is simpler to read too: datalen := removedKeyken // removedKeyken must have been int32 in your example. if value != nil {

Re: [go-nuts] Go if else syntax .. suggested replacement

2019-04-24 Thread Robert Engels
I’m pretty sure you’re joking... but I think most are referring to simple usages, like this (from my own code). Clearly, there are others was of designing it to avoid the usage, but sometimes what is simple really is simpler. var datalen int32 if value == nil { datalen = removedKeyken }

Re: [go-nuts] Go if else syntax .. suggested replacement

2019-04-24 Thread Marcus Low
color := map[bool]string{true:"red",false:"green"}[temperature>80] Here you go. On Wednesday, April 24, 2019 at 10:08:53 PM UTC+8, Mark Volkmann wrote: > > Are there really developers that find this unreadable? > > color := temperature > 80 ? “red” : “green” > > I know what you are going to

Re: [go-nuts] Go if else syntax .. suggested replacement

2019-04-24 Thread Marcus Low
I personally do not find ternary operators to be readable in any form. For those who are truly desperate for that cosmetic one-line kick, though, here's an example you can use (which looks just about as unreadable as any ternary operator out there): // ternary returns 12345 if x is positive (x

Re: [go-nuts] Go if else syntax .. suggested replacement

2019-04-24 Thread Robert Engels
Yes, but the FAQ has similar concerns about readability and maintainability as reasons for not having generics, but adds the language “may change”... not sure that is consistent with the views on the tenant operator. > On Apr 24, 2019, at 9:52 AM, Ian Lance Taylor wrote: > > The lack of the

[go-nuts] Re: Is there a way to force to pass some function or error check when Debugging?

2019-04-24 Thread jake6502
On Tuesday, April 23, 2019 at 1:43:52 AM UTC-4, hui zhang wrote: > > I am debugging a linux server program in local mac machine. > some code related to environment check , such as check mount point etc. > > I want to pass this check , how ? > >- I try it set return error var to nil. but

Re: [go-nuts] Go if else syntax .. suggested replacement

2019-04-24 Thread Ian Lance Taylor
The lack of the ?: operator in Go is a FAQ: https://golang.org/doc/faq#Does_Go_have_a_ternary_form . Ian -- 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] cannot use CallBack (type func(*_Ctype_char, *_Ctype_char, _Ctype_ulong)) as type *[0]byte in argument to _Cfunc_reload_pattern_db

2019-04-24 Thread Jan Mercl
On Wed, Apr 24, 2019 at 4:16 PM Nitish Saboo wrote: > >>Why size_t, char is going to be undefined here ? I followed the exact steps > >>mentioned in 'https://github.com/golang/go/wiki/cgo#function-variables' > >>under the topic 'Function pointer callback'. > I have to pass the callback

Re: [go-nuts] cannot use CallBack (type func(*_Ctype_char, *_Ctype_char, _Ctype_ulong)) as type *[0]byte in argument to _Cfunc_reload_pattern_db

2019-04-24 Thread Nitish Saboo
On Wed, Apr 24, 2019 at 1:51 PM Nitish Saboo wrote: > > Hi, > > I followed the link ' https://github.com/golang/go/wiki/cgo#function-variables' and made the following changes: > 1)main.go > package main > //#cgo CFLAGS: -I./syslog-ng-3.6.2/ > //#cgo LDFLAGS: syslog-node.so > //#cgo LDFLAGS:

Re: [go-nuts] Go if else syntax .. suggested replacement

2019-04-24 Thread Mark Volkmann
Are there really developers that find this unreadable? color := temperature > 80 ? “red” : “green” I know what you are going to say. People will nest them. But even nested usage can be readable when formatted nicely with one condition per line. Another alternative is to allow only unnested

Re: [go-nuts] Go if else syntax .. suggested replacement

2019-04-24 Thread Jan Mercl
On Wed, Apr 24, 2019 at 3:48 PM L Godioleskky wrote: > > The lack of a Go ternary operator is at odds with Go's major theme of clean > and easy to read syntax. Those who choose not to use the ternary operator can > always resort back to Go's current 'if -else' or 'case' syntax. So Go syntax >

Re: [go-nuts] Go if else syntax .. suggested replacement

2019-04-24 Thread L Godioleskky
The lack of a Go ternary operator is at odds with Go's major theme of clean and easy to read syntax. Those who choose not to use the ternary operator can always resort back to Go's current 'if -else' or 'case' syntax. So Go syntax suffers no negative impact by adding the ternary op to its syntax

[go-nuts] Re: Does fmt.Fprint use WriteString ?

2019-04-24 Thread codiglot
That's interesting and good to know. I guess it should be expected given that Fprint does a bit more work using it's internal printer struct and buffer. On Tuesday, April 23, 2019 at 1:43:55 PM UTC-4, Constantin Konstantinidis wrote: > > The result is equivalent but a micro-benchmark shows

[go-nuts] Re: Gomobile Reverse Bindings: Cannot import any android packages

2019-04-24 Thread Mark Bauermeister
Yea. Turns out that was indeed the issue. I tried accessing a method that didn't actually exist. Unfortunately, your code doesn't work either. It leads to a segmentation violation/nil pointer error. I suspect one needs to somehow get the right context from the Java side. Question is how. I

[go-nuts] Re: Gomobile Reverse Bindings: Cannot import any android packages

2019-04-24 Thread mail
On Wednesday, April 24, 2019 at 2:34:34 PM UTC+2, Mark Bauermeister wrote: > > I'm currently experimenting with Gomobile Reverse Bindings (my hope is to > eventually be able to call getFilesDir(), so I can save my SQLite3 DB on > mobile) and it is, quite literally, driving me insane. > I've

[go-nuts] Gomobile Reverse Bindings: Cannot import any android packages

2019-04-24 Thread Mark Bauermeister
I'm currently experimenting with Gomobile Reverse Bindings (my hope is to eventually be able to call getFilesDir(), so I can save my SQLite3 DB on mobile) and it is, quite literally, driving me insane. I've followed the sparse information available, was able to successfully work with 'import

Re: [go-nuts] Change in virtual memory patterns in Go 1.12

2019-04-24 Thread kevin . a . conaway
Hi Michael, I found my way to this thread as we are experiencing similar issues in one of our applications after upgrading from 1.11.1 to 1.12.4. Our application has a lot of persistent, large, busy maps so we periodically recreate them per https://github.com/golang/go/issues/20135. What we

Re: [go-nuts] how to test main function coverage with different args

2019-04-24 Thread J. Santos
Hi, I think you could set the `os.Args` before calling your main. -- Jota On Tue, Apr 23, 2019, 6:03 AM hui zhang wrote: > how to test main function coverage with different args to enhance > coverage rate > how to cover the red part ? for you can set args once a time > > func Test_main(m

Re: [go-nuts] [RFC][Gomobile] Wrote a series of posts on Gomobile

2019-04-24 Thread Reto
On Tue, Apr 23, 2019 at 08:46:15PM -0700, Girish Koundinya wrote: > Any feedback is welcome :) Well, for starters please return early from functions instead of nesting it 4 levels deep, like in the example below (getContacts)

Re: [go-nuts] Go if else syntax .. suggested replacement

2019-04-24 Thread Robert Engels
That’s not what he meant. It takes 5 lines for a trivial assignment if/else rather than 1 line with a ternary with no loss in readability. > On Apr 24, 2019, at 7:11 AM, Jan Mercl <0xj...@gmail.com> wrote: > >> On Wed, Apr 24, 2019 at 2:04 PM Mark Volkmann >> wrote: >> >> The idea of adding

Re: [go-nuts] Go if else syntax .. suggested replacement

2019-04-24 Thread Jan Mercl
On Wed, Apr 24, 2019 at 2:04 PM Mark Volkmann wrote: > The idea of adding the ternary operator to Go has been debated many times. > It’s clear that those in charge have a strong dislike for it. For me the lack > of the ternary operator is one of main things I dislike about Go. It’s nails > on

Re: [go-nuts] cannot use CallBack (type func(*_Ctype_char, *_Ctype_char, _Ctype_ulong)) as type *[0]byte in argument to _Cfunc_reload_pattern_db

2019-04-24 Thread Jan Mercl
On Wed, Apr 24, 2019 at 1:51 PM Nitish Saboo wrote: > > Hi, > > I followed the link > 'https://github.com/golang/go/wiki/cgo#function-variables' and made the > following changes: > 1)main.go > package main > //#cgo CFLAGS: -I./syslog-ng-3.6.2/ > //#cgo LDFLAGS: syslog-node.so > //#cgo LDFLAGS:

Re: [go-nuts] Go if else syntax .. suggested replacement

2019-04-24 Thread Mark Volkmann
> On Apr 24, 2019, at 6:22 AM, Robert Engels wrote: > > Though to the ops point, not sure why Go doesn’t have the ternary operator - > which is pretty ubiquitous. The idea of adding the ternary operator to Go has been debated many times. It’s clear that those in charge have a strong

[go-nuts] Benchmark Issue with list of cpu counts

2019-04-24 Thread pointadvance
I'm writing a simple benchmark to observe speedup with increased cores, I'm having an issue where the for core count of 1, it still uses GOMAXPROCS (in my case 4, hyper-threading turned off). I'm thinking its just a flag is not set right, but I'm putting foward everything I know, because I

Re: [go-nuts] cannot use CallBack (type func(*_Ctype_char, *_Ctype_char, _Ctype_ulong)) as type *[0]byte in argument to _Cfunc_reload_pattern_db

2019-04-24 Thread Nitish Saboo
Hi, I followed the link ' https://github.com/golang/go/wiki/cgo#function-variables' and made the following changes: *1)main.go* package main //#cgo CFLAGS: -I./syslog-ng-3.6.2/ //#cgo LDFLAGS: syslog-node.so //#cgo LDFLAGS: -L/usr/local/lib/ -lsyslog-ng //#cgo LDFLAGS: -L/usr/local/lib/syslog-ng

Re: [go-nuts] Go if else syntax .. suggested replacement

2019-04-24 Thread Robert Engels
Though to the ops point, not sure why Go doesn’t have the ternary operator - which is pretty ubiquitous. > On Apr 23, 2019, at 9:56 PM, Robert Engels wrote: > > Why? You have saved 5 characters for no practical gain. I think you would > enjoy Ada. > >> On Apr 23, 2019, at 8:05 PM,

Re: [go-nuts] cannot use CallBack (type func(*_Ctype_char, *_Ctype_char, _Ctype_ulong)) as type *[0]byte in argument to _Cfunc_reload_pattern_db

2019-04-24 Thread Jan Mercl
On Wed, Apr 24, 2019 at 10:47 AM Nitish Saboo wrote: > ./main.go:80:32: cannot use key (type *_Ctype_char) as type string in map > index func CallBack(ckey *C.char, value *C.char, value_len C.size_t){ key := C.GoString(ckey) if remap, ok := field_mappings[key]; ok {

[go-nuts] cannot use CallBack (type func(*_Ctype_char, *_Ctype_char, _Ctype_ulong)) as type *[0]byte in argument to _Cfunc_reload_pattern_db

2019-04-24 Thread Nitish Saboo
Hi, I am facing the following issue: I have a GO code that has to be called from the C code: var field_mappings map[string]string = map[string]string{ " A": "a", "B": "b", "C": "c", "D": "d"} //export CallBack func CallBack(key *C.char, value *C.char, value_len C.size_t){

Re: [go-nuts] Go if else syntax .. suggested replacement

2019-04-24 Thread Jan Mercl
On Wed, Apr 24, 2019 at 3:05 AM wrote: > > It sure would be nice if Go syntax allowed programmers to replace > > if ( test) { > ...do sonething > } That's not how Go's if statement looks. Gofmt will remove the superficial parentheses around 'test'. Wrt the rest of the proposal, today, this is

[go-nuts] Re: Go if else syntax .. suggested replacement

2019-04-24 Thread wilk
On 24-04-2019, lgod...@gmail.com wrote: > --=_Part_538_706677508.1556067911841 > Content-Type: multipart/alternative; > boundary="=_Part_539_1965717614.1556067911841" > > --=_Part_539_1965717614.1556067911841 > Content-Type: text/plain; charset="UTF-8" > > It sure would be nice

[go-nuts] Re: how to test main function coverage with different args

2019-04-24 Thread Miki Tebeka
You can use table driven test, see https://github.com/golang/go/wiki/TableDrivenTests On Tuesday, April 23, 2019 at 12:03:15 PM UTC+3, hui zhang wrote: > > how to test main function coverage with different args to enhance > coverage rate > how to cover the red part ? for you can set args once