Re: [go-nuts] An old problem: lack of priority select cases

2019-09-01 Thread Albert Tedja
This is something I ran into a while back, and made a library for it, though, I prefer not to spam the mailing list. Feel free to send me a dm and I'll send you a github link if you are interested. On Sunday, September 1, 2019 at 3:02:52 AM UTC-7, T L wrote: > > > > On Sunday, September 1, 2019

[go-nuts] By passing go type check when performing bitwise operator

2019-09-01 Thread Albert Tedja
I am trying to perform some bitwise operators, but Go is not letting me because the mask is an uint and the values are int. Setting the mask to int will break the code since I am shifting bits right and left and prefer the prefix 0 when shifting right, and if I am not mistaken, Go does not have

[go-nuts] Re: Closed channel vs nil channel when writing

2019-09-01 Thread Albert Tedja
No such thing as a 'nil channel'. You are merely setting a variable to nil, regardless what the previous content is. It's just that Go allows you to receive from a nil variable if that variable's type is a channel, in which case it blocks forever. On Sunday, September 1, 2019 at 9:03:58 AM UT

[go-nuts] net/http Server Shutdown does not free up the port upon return

2017-11-28 Thread Albert Tedja
net/http's Shutdown() does not free up the port upon return, or rather it seems a bit undefined how long it takes for the port to be reusable again. server := &http.Server{ Addr: fmt.Sprintf(":9000"), } go func() { fmt.Println("hosting...") err := server.Listen

[go-nuts] Re: is this safe?

2017-11-21 Thread Albert Tedja
You need to swap elements if you want to remove them from list while iterating it. There are two ways to do this: First: iterate backward. This will however, will change the order of unremoved elements. Second: iterate forward, and will preserve the order of the unremoved elements. https://pl

[go-nuts] Re: My trouble of local package referencing

2017-11-16 Thread Albert Tedja
Yes, it's a debatable subject within the Go community. See this blog for example: https://medium.com/@c9s/golang-the-annoying-remote-import-path-c6c7e76517e5 There are some tricks you can do using a different git remote, `git remote add myfork github.com/yourfork/project` Then when you push, y

[go-nuts] Re: golang and http2

2017-11-15 Thread Albert Tedja
Thank you for the links. I am still somewhat disappointed that the http/2 protocol would enforce a certain configuration. I understand the necessity of secure connections, but that's should be left as an option to the developers. If browsers want to strictly use TLS, that's fine because it's co

[go-nuts] golang and http2

2017-11-14 Thread Albert Tedja
I am reading Golang's support for HTTP2, and it seems it is only enabled by default if you use https https://go-review.googlesource.com/c/go/+/15828 My questions are: 1. Does this mean I have to use ListenAndServeTLS() to enable http2 and if not, it will fallback to HTTP1.1? 2. Can I explicitly

Re: [go-nuts] Writing your own Context, making sure it's compatible with context.Context

2017-11-09 Thread Albert Tedja
> Can you just have a field of your Context type be a value of type > context.Context? > > Ian > I managed to do this eventually. The confusion was that my library has multiple types of contexts and they need to be stacked in any particular order. So at first, the values from previous (pare

[go-nuts] Writing your own Context, making sure it's compatible with context.Context

2017-11-08 Thread Albert Tedja
I am writing a library that could use the benefit of context, but I also want to add additional functionalities to the context my library using, while keeping the same golang idiom of using With*() to create a new context based off its parent. At first, it seems that all I need to do is to sati

Re: [go-nuts] A way to detect closed channel

2017-11-06 Thread Albert Tedja
That makes sense. If multiple goroutines are calling that select block, one or more could be attempting to close it. Okay, nevermind then. -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receiving emails

[go-nuts] Re: A way to detect closed channel

2017-11-06 Thread Albert Tedja
Assuming of course, that the channel is only intended to send closed signal to other goroutines, rather than transporting meaningful data. On Monday, November 6, 2017 at 4:59:51 PM UTC-8, Albert Tedja wrote: > > So, I just found out that closed channels always yield the zero value. > T

[go-nuts] A way to detect closed channel

2017-11-06 Thread Albert Tedja
So, I just found out that closed channels always yield the zero value. That means, a closed channel inside a select statement seems to always be guaranteed to be executed. Since closing an already closed channel creates a panic, does this mean then I can do this to make sure that the channel is

[go-nuts] Re: Writing a non-blocking thread-safe buffer

2017-04-07 Thread Albert Tedja
I don't think using separate write/read channels do anything much here. If you are concerned goroutines reading the channel somehow slowing down the writes, you already have a goroutine that's doing the transfer on the other end. On Friday, April 7, 2017 at 8:36:14 AM UTC-7, Eno Compton wrot

Re: [go-nuts] dep: Roadmap for merging into the toolchain

2017-03-13 Thread Albert Tedja
I was using godeps before and now govendor, and never felt 100% happy with either one. I have some feedback of how I think the package management tool should work from the developer perspective, and here some features that I think is crucial. 1. Standardize the package file. With govendor, t

[go-nuts] Re: Does sync.Cond call Lock() twice on the underlying Locker?

2017-03-13 Thread Albert Tedja
: > > > > On Tuesday, March 14, 2017 at 12:10:31 AM UTC+2, Albert Tedja wrote: >> >> I am writing a custom Locker which does a check if Lock() is being called >> more than once and throws a panic if it does. >> I tested it to see if I can use it with sync.Cond, and f

[go-nuts] Re: Does sync.Cond call Lock() twice on the underlying Locker?

2017-03-13 Thread Albert Tedja
$ go version go version go1.8 linux/amd64 -- 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. For more options, visit https:

[go-nuts] Does sync.Cond call Lock() twice on the underlying Locker?

2017-03-13 Thread Albert Tedja
I am writing a custom Locker which does a check if Lock() is being called more than once and throws a panic if it does. I tested it to see if I can use it with sync.Cond, and for the most part, it was running as intended, except once in a while the panic check triggered. Here's the dumbed down v

Re: [go-nuts] thread safety of map when each goroutine access a different key

2017-03-13 Thread Albert Tedja
Great. Thanks! Looks like it's just better if I return a struct if these goroutines are operating independently anyway. On Monday, March 13, 2017 at 12:20:42 AM UTC-7, Konstantin Khomoutov wrote: > > On Sun, 12 Mar 2017 23:39:59 -0700 (PDT) > Albert Tedja > wrote: > > &g

[go-nuts] thread safety of map when each goroutine access a different key

2017-03-12 Thread Albert Tedja
Hello, I know map itself isn't threadsafe, but I am just wondering how threadsafe it is if you can be absolutely sure that each goroutine accesses a different key in the map. Say, goroutine 1 accesses mymap["1"] and goroutine 2 accesses mymap["2"] and so on. Thank you in advance. -- You recei