[go-nuts] Why doesn't Go include a contains method for things like slices?

2019-11-05 Thread toddsurfs via golang-nuts
Sorry if this question reveals my newness to Go. I tried searching the mailing list but I couldn't find anything in a quick search. It seems like many languages include the ability to check if an array, or slice contain a particular value. I understand that you could do this easily with a for

Re: [go-nuts] Why doesn't Go include a contains method for things like slices?

2019-11-05 Thread Robert Engels
Is it though?You would have the same problem if you thought the size of mySlice was always small, and it wasn't - range could be quite expensive (or not) - and if that was not valid workable you should be using something other than a slice.You need understanding of the types and cost of operations

[go-nuts] Auto-renew letsencrypt cert with standard library code

2019-11-05 Thread Sean Liao
1. Check certificate expiry (stdlib) 2. Implement ACME client to request certificate 3. Respond to a challenge (the http one is easy) 4. Restart server with new certificate -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this

Re: [go-nuts] Why doesn't Go include a contains method for things like slices?

2019-11-05 Thread Robert Engels
I think that’s splitting hairs a bit. Even if you see the loop you don’t know the cost unless you know the size of a slice. For instance, a lookup in a small slice is actually cheaper than a small map - in memory and speed. So you need to know more than “it’s a slice” to make a judgement. >

Re: [go-nuts] Why doesn't Go include a contains method for things like slices?

2019-11-05 Thread Tyler Compton
I agree with you that an original writer of the code should be expected to know that a theoretical "contains" or "in" expression has O(n) properties. However, I've always thought of this from the perspective of someone looking at the code later and trying to identify performance issues. It's easy

Re: [go-nuts] Why doesn't Go include a contains method for things like slices?

2019-11-05 Thread Tyler Compton
I should mention that I don't 100% buy this argument and I would still like to see a "slices.Contains" function in the future if/when generics are added. I'm trying (perhaps poorly) to explain what I've seen as the most common argument against adding such a feature. On Tue, Nov 5, 2019 at 3:58 PM

[go-nuts] Auto-renew letsencrypt cert with standard library code

2019-11-05 Thread Michael Ellis
I have the code at the bottom of this message in a web server I'm running in a Digital Ocean Droplet. The app is a simple ear training program for instrumentalists. The URL is https://etudes.ellisandgrant.com. It works with no problems until the letsencrypt certificate

Re: [go-nuts] Why doesn't Go include a contains method for things like slices?

2019-11-05 Thread Tyler Compton
Ian's answer addresses your question about the absence of a slice.Contains method, but there have been discussions in the past about adding such a feature to the language itself as well. You brought up the idea of a builtin "contains" function, and I've seen others suggest adding something like

Re: [go-nuts] Why doesn't Go include a contains method for things like slices?

2019-11-05 Thread Ian Lance Taylor
On Tue, Nov 5, 2019 at 12:30 PM toddsurfs via golang-nuts wrote: > > Sorry if this question reveals my newness to Go. I tried searching the > mailing list but I couldn't find anything in a quick search. It seems like > many languages include the ability to check if an array, or slice contain a

Re: [go-nuts] Auto-renew letsencrypt cert with standard library code

2019-11-05 Thread Kurtis Rader
FWIW, The Caddy web server is written in Go and handles this scenario. So you might consider using it or at least looking at its source to understand how to implement this feature. On Tue, Nov 5, 2019 at 9:20 AM Michael Ellis wrote: > > I have the code at the bottom of this message in a

Re: [go-nuts] Auto-renew letsencrypt cert with standard library code

2019-11-05 Thread Marko Ristin-Kaufmann
Hi, FWIW, The Caddy web server is written in Go and handles this scenario. So > you might consider using it or at least looking at its source to understand > how to implement this feature. > We implemented an alternative in case you need more examples: https://github.com/Parquery/revproxyry