Re: [go-nuts] Bring back slices.BinarySearchFunc with a predicate

2022-04-04 Thread 'Axel Wagner' via golang-nuts
Sorry, the predicate should be var b T pred := func(a T) bool { return cmp(a, b) >= 0 } On Tue, Apr 5, 2022 at 7:27 AM Axel Wagner wrote: > Hm I must say, I also don't really understand removing the predicate-based > one. It is easy, when you have a comparison function, to get to a predicate:

Re: [go-nuts] Bring back slices.BinarySearchFunc with a predicate

2022-04-04 Thread 'Axel Wagner' via golang-nuts
Hm I must say, I also don't really understand removing the predicate-based one. It is easy, when you have a comparison function, to get to a predicate: pred := func(a, b T) bool { return cmp(a, b) >= 0 } But not the other way around, so a predicate is more general. I used the predicate version of

Re: [go-nuts] build unoptimized std lib for debugging

2022-04-04 Thread Ian Lance Taylor
On Mon, Apr 4, 2022 at 5:16 PM arthurwil...@gmail.com wrote: > > > > On Monday, April 4, 2022 at 7:00:49 PM UTC-5 arthurwil...@gmail.com wrote: >> >> On Monday, April 4, 2022 at 6:14:30 PM UTC-5 Ian Lance Taylor wrote: >>> >>> On Mon, Apr 4, 2022 at 3:49 PM arthurwil...@gmail.com >>> wrote: >>>

Re: [go-nuts] build unoptimized std lib for debugging

2022-04-04 Thread arthurwil...@gmail.com
On Monday, April 4, 2022 at 7:00:49 PM UTC-5 arthurwil...@gmail.com wrote: > On Monday, April 4, 2022 at 6:14:30 PM UTC-5 Ian Lance Taylor wrote: > >> On Mon, Apr 4, 2022 at 3:49 PM arthurwil...@gmail.com >> wrote: >> > >> > >> > >> > On Sunday, April 3, 2022 at 10:35:04 PM UTC-5 Ian

Re: [go-nuts] build unoptimized std lib for debugging

2022-04-04 Thread arthurwil...@gmail.com
On Monday, April 4, 2022 at 6:14:30 PM UTC-5 Ian Lance Taylor wrote: > On Mon, Apr 4, 2022 at 3:49 PM arthurwil...@gmail.com > wrote: > > > > > > > > On Sunday, April 3, 2022 at 10:35:04 PM UTC-5 Ian Lance Taylor wrote: > >> > >> On Sun, Apr 3, 2022 at 6:21 PM arthurwil...@gmail.com >

Re: [go-nuts] build unoptimized std lib for debugging

2022-04-04 Thread Ian Lance Taylor
On Mon, Apr 4, 2022 at 3:49 PM arthurwil...@gmail.com wrote: > > > > On Sunday, April 3, 2022 at 10:35:04 PM UTC-5 Ian Lance Taylor wrote: >> >> On Sun, Apr 3, 2022 at 6:21 PM arthurwil...@gmail.com >> wrote: >> > >> > I'm trying to build an unoptimized version of the standard library for >> >

[go-nuts] Re: Why can't an interface type be a receiver

2022-04-04 Thread Simon Archer
I think that playground is broken. *./prog.go:22:9: undefined: translatableImpl./prog.go:27:11: undefined: translatableImplGo build failed.* I fixed it like this: https://go.dev/play/p/vZlwZIe9Ras On Monday, April 4, 2022 at 1:27:46 PM UTC-4 Ron Green wrote: > in case anyone get's here

[go-nuts] Bring back slices.BinarySearchFunc with a predicate

2022-04-04 Thread Sudhir Jonathan
The earlier method signature for slices.BinarySearchFunc was very useful: It was of the form ``` slices.BinarySearchFunc(array, func(e T) bool) ``` which returned the smallest index at which predicate would return true. This was incredibly useful to do inequality operation binary searches -

Re: [go-nuts] build unoptimized std lib for debugging

2022-04-04 Thread arthurwil...@gmail.com
On Sunday, April 3, 2022 at 10:35:04 PM UTC-5 Ian Lance Taylor wrote: > On Sun, Apr 3, 2022 at 6:21 PM arthurwil...@gmail.com > wrote: > > > > I'm trying to build an unoptimized version of the standard library for > debugging. > > You can just use > > go build -gcflags=all="-N -l" > >

Re: [go-nuts] Convert string to time.Duration

2022-04-04 Thread vika...@gmail.com
Thanks all for the hint and the snippets. I am all set now. On Tuesday, 5 April 2022 at 00:13:46 UTC+10 tay...@fastmail.com wrote: > Take a look at time.ParseDuration and its example: > https://pkg.go.dev/time#ParseDuration > > On Sun, Apr 3, 2022, at 3:48 PM, vika...@gmail.com wrote: > > I am

Re: [go-nuts] Looked at using Go ... nil/SEGV really bothered me .. Go2 Proposal?

2022-04-04 Thread Sam Hughes
I was really annoyed that, apparently, I accidentally deleted the message you're replying to, immediately after writing it. I agree with you about being possibly surprised by values of outside of an expected range. The benefit of the above is merely that accessing it is guaranteed to be

[go-nuts] Re: Why can't an interface type be a receiver

2022-04-04 Thread Ron Green
in case anyone get's here and is confused... you can wrap the additional functionality in the struct and use the interfaces from before https://go.dev/play/p/e8aS0PZC6Zh On Monday, February 2, 2015 at 2:55:30 PM UTC+2 oju...@gmail.com wrote: > The code start to get smart when you combine

[go-nuts] [security] Go 1.18.1 and Go 1.17.9 pre-announcement

2022-04-04 Thread Julie Qiu
Hello gophers, We plan to issue Go 1.18.1 and Go 1.17.9 on Thursday, April 7th. These minor releases include a PRIVATE security fix to the standard library. Following our security policy, this is the pre-announcement of those releases. Thanks, Julie on behalf of the Go team -- You received

Re: [go-nuts] Convert string to time.Duration

2022-04-04 Thread taylor
Take a look at time.ParseDuration and its example: https://pkg.go.dev/time#ParseDuration On Sun, Apr 3, 2022, at 3:48 PM, vika...@gmail.com wrote: > I am looking to convert a *string* (say 4) to type *time.Duration*. > > I've looked around but could not find a way to do so. > > //

[go-nuts] Re: Java to Go converter - 2

2022-04-04 Thread alex-coder
*Another use case for automatically translating codewritten in Java to Golang is Exception Handling.The next example is likely to be about multithreading.Example in Java:* package com.builder.start.here; public class CatchException { public static void main(String[] args) { try

[go-nuts] Re: Convert string to time.Duration

2022-04-04 Thread Amnon
Use time.ParseDuration() https://go.dev/play/p/SWUHBiSpflh On Sunday, 3 April 2022 at 23:48:54 UTC+1 vika...@gmail.com wrote: > I am looking to convert a *string* (say 4) to type *time.Duration*. > > I've looked around but could not find a way to do so. > > // https://go.dev/play/p/EUuDAY-Qx8N