Re: [go-nuts] Re: Why there is no net.ListenContext?

2023-12-21 Thread Michał Matczuk
Hey.

net.ListenConfig does not document the context usage. The docs just point 
to Listen. I'd expect that cancelling the context would stop the listener 
but it's not the case. 

The questions are:

* Should Listener created with net.ListenConfig.Listen be closed - is that 
a bug, if not why?
* Is the above document anywhere?

wtorek, 19 grudnia 2023 o 22:21:27 UTC+1 Axel Wagner napisał(a):

> Hm, reading again, I don't think I actually understand your question. You 
> clearly are ListenConfig aware.
> But what do you mean with "the same way we have Dial and DialContext"? 
> These are methods on Dialer, so ISTM that there is indeed a pretty clear 
> correspondence. Except that Dialer.Dial has been introduced in Go 1.1, 
> before we had context.Context, so we needed a new name for the 
> context-aware API.
> So I'm not sure what exactly you are asking. ISTM you are not missing a 
> context-aware version of Listen, so what is it you are asking for?
>
> On Tue, Dec 19, 2023 at 10:14 PM Axel Wagner  
> wrote:
>
>> You can use `ListenConfig.Listen` to do this:
>> https://pkg.go.dev/net#ListenConfig.Listen
>> I believe the reason to do it this way was the realization that there 
>> will probably be more ways to set up listening in the future and having 
>> lots of different ListenFoo functions in the package would overload the 
>> namespace too much.
>>
>> On Tue, Dec 19, 2023 at 9:28 PM Michał Matczuk  wrote:
>>
>>> The context is passed downstream but cancelling it seems to have no 
>>> effect.
>>> I guess that the reason why it's not exported.
>>> Can anyone shed more light on it?   
>>>
>>> wtorek, 19 grudnia 2023 o 11:59:49 UTC+1 Michał Matczuk napisał(a):
>>>
>>>> If you take a look at net.Listen implementation
>>>>
>>>> func Listen(network, address string) (Listener, error) {
>>>> var lc ListenConfig
>>>> return lc.Listen(context.Background(), network, address)
>>>> }
>>>>
>>>> you will notice the new listen API net.ListenConfig.
>>>>
>>>> This API is context aware, I think it would be handy if we had 
>>>> net.ListenContext the same way we have Dial and DialContext.
>>>>
>>>> Any thoughts on that?
>>>>
>>> -- 
>>> 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 golang-nuts...@googlegroups.com.
>>> To view this discussion on the web visit 
>>> https://groups.google.com/d/msgid/golang-nuts/8abe1abb-eb3b-4632-b3c0-e430f2f42270n%40googlegroups.com
>>>  
>>> <https://groups.google.com/d/msgid/golang-nuts/8abe1abb-eb3b-4632-b3c0-e430f2f42270n%40googlegroups.com?utm_medium=email_source=footer>
>>> .
>>>
>>

-- 
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 golang-nuts+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/48237db5-fe65-4dad-8035-b8c32643219an%40googlegroups.com.


[go-nuts] Re: Why there is no net.ListenContext?

2023-12-19 Thread Michał Matczuk
The context is passed downstream but cancelling it seems to have no effect.
I guess that the reason why it's not exported.
Can anyone shed more light on it?   

wtorek, 19 grudnia 2023 o 11:59:49 UTC+1 Michał Matczuk napisał(a):

> If you take a look at net.Listen implementation
>
> func Listen(network, address string) (Listener, error) {
> var lc ListenConfig
> return lc.Listen(context.Background(), network, address)
> }
>
> you will notice the new listen API net.ListenConfig.
>
> This API is context aware, I think it would be handy if we had 
> net.ListenContext the same way we have Dial and DialContext.
>
> Any thoughts on that?
>

-- 
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 golang-nuts+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/8abe1abb-eb3b-4632-b3c0-e430f2f42270n%40googlegroups.com.


[go-nuts] Why there is no net.ListenContext?

2023-12-19 Thread Michał Matczuk
If you take a look at net.Listen implementation

func Listen(network, address string) (Listener, error) {
var lc ListenConfig
return lc.Listen(context.Background(), network, address)
}

you will notice the new listen API net.ListenConfig.

This API is context aware, I think it would be handy if we had 
net.ListenContext the same way we have Dial and DialContext.

Any thoughts on that?

-- 
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 golang-nuts+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/73488643-5102-45e5-a91d-9d19f6523ec2n%40googlegroups.com.


[go-nuts] Re: yet another code gen: specialized datastructure

2021-03-15 Thread Michał Matczuk
I invite you to take a look at [1] a bazel-free version of Google 
go_generics tool 
 released 
with gVisor project. It is used to make [2].

[1] https://github.com/mmatczuk/go_generics 
[2] https://github.com/scylladb/go-set

niedziela, 14 marca 2021 o 13:50:37 UTC+1 clement...@gmail.com napisał(a):

> hi,
>
> I recently wanted to get the juice out of some programs. 
> A queue consumer that transforms inputs over many routines,
> then aggregates the results to re order them.
> The order is defined by the input order.  
>
> There was many variations written around it,
> using a map, a slice, a regular heap, and finally,
> a specialized heap (hand written).
>
> Slice was best for its simplicity, regular heap made 
> with the package `container/heap` was not as good as expected.
> The specialized heap was the best for performance,
> but having this added complexity for only one small
> library of ~100LOC did not seem a good idea.
>
> So I wrote a template, included and rewrote the tests from
> `container/heap`, et voilà, it makes sense. 
> It is tested, re usable, and made for perf.
>
> The template are available at 
> https://github.com/clementauger/jenjen-datastructure
>
> Then you run (or add it via //go:gen..) 
> jenjen -template=github.com/clementauger/jenjen-datastructure/heap \ 
> - "U => -, T => -, Heap=>MinIntHeap , MinIntHeap:U=>int, MinIntHeap:T=> 
> minInt"
>
> It generates for you a Heap that takes in input regular ints, output 
> regular ints, but internally stores them as minInt.
> See 
> https://github.com/clementauger/jenjen-datastructure/blob/main/examples/heap/jenjen_heap.go#L38
>
> So does it do any good ? 
>
> $ (cd examples/heap; go test -bench=. -benchmem -count=2)
> goos: linux
> goarch: amd64
> pkg: github.com/clementauger/jenjen-datastructure/examples/heap
> BenchmarkMinIntHeap-49439108133 ns/op   8 
> B/op   0 allocs/op
> BenchmarkMinIntHeap-4   1107884 ns/op   8 
> B/op   0 allocs/op
> BenchmarkRegularHeap-4   3523325731 ns/op  23 
> B/op   0 allocs/op
> BenchmarkRegularHeap-4   3433321977 ns/op  23 
> B/op   0 allocs/op
> PASS
> ok  github.com/clementauger/jenjen-datastructure/examples/heap   
>  4.452s
>
> (I hope i have not made a mistake writing the comparison benchmarks, i 
> would not like to criticize the core language implementation in such 
> fashion...)
>
> Notes: 
> 1/ I have to say i was surprised to not find an existing similar project 
> using genny  (a more popular code 
> generator), did i miss something ?
>
> Clément
>

-- 
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 golang-nuts+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/3b6061b1-1240-4edc-9d62-8c8e826c24f4n%40googlegroups.com.


[go-nuts] Re: Tools for managing licenses of dependencies

2020-04-14 Thread Michał Matczuk
I'm using https://github.com/src-d/go-license-detector with some bash 
scripting around it to list the modules.

On Saturday, April 11, 2020 at 10:03:18 PM UTC+2, Victor Denisov wrote:
>
> Hi,
>
> Are there any tools that would allow to manage licenses of my go modules?
> I would like to be able to specify what licenses of my dependencies are 
> allowed.
>
> Are there any plans to add something like this to standard go tools?
>
> Thanks,
> Victor.
>

-- 
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 golang-nuts+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/69d10250-6c62-49ab-9b33-d941db44e87c%40googlegroups.com.