Re: [go-nuts] Generic function aliases
It is pity `func g = othermod.F` were rejected. It could simplify refactoring. For example, I've decided to move type and its constructor to other package. I could easily alias type in its previous place to remain compatibility, but I have to write ugly wrapper for constructor: type SomeEntity = otherpackage.SomeEntity func NewSomeEntity(arg1 Arg1, arg2 Arg2, arg3 Arg3, opts ...Opt) *SomeEntry { return otherpackage.SomeEntity(arg1, arg2, opts...) } compared to type SomeEntity = otherpackage.SomeEntity func NewSomeEntity = otherpackage.NewSomeEntity среда, 5 декабря 2018 г. в 00:14:42 UTC+3, axel.wa...@googlemail.com: > This was considered (or rather, the `func g = f` syntax), but ultimately > it was decided that the current ways to forward functions are good enough > :) Either use var, or if you are uncomfortable with having that > *theoretically* mutable, wrap it directly (it should get inlined, so > there's no cost apart from writing the wrapper). > > On Tue, Dec 4, 2018 at 8:34 PM Liam Breck wrote: > >> I meant this should work >> >> https://play.golang.org/p/w6MBzP9RNdH >> >> On Tue, Dec 4, 2018, 11:21 AM messju mohr > wrote: >> >>> Erm, function names may be const, but functions are first class citizen >>> types and can of course be assigned to variables and be passed around. >>> >>> just my 2c >>> >>> On Tue, Dec 04, 2018 at 10:27:19AM -0800, Liam Breck wrote: >>> >Ah yes, var works. But it should be const, since func names aren't >>> >variables. >>> >On Tue, Dec 4, 2018, 5:40 AM Axel Wagner <[1] >>> axel.wa...@googlemail.com >>> >wrote: >>> > >>> > You can use >>> > var Gi = g.G(int) >>> > or you can use >>> > func Gi(i int) error { return g.G(i) } >>> > for the same effect. Which is pretty much the reason why >>> > alias-declarations ended up only be added for types - all other >>> > declarations can already be emulated sufficiently well. :) >>> > On Mon, Dec 3, 2018 at 11:39 PM Liam Breck <[2] >>> li...@networkimprov.net> >>> > wrote: >>> > >>> >Type aliases appear in the contracts draft design. Has anyone >>> >suggested alias declarations for generic functions? This would >>> >simplify syntax for callers... >>> >package g >>> >func G(type T)(i T) error { ... } >>> >--- >>> >package main >>> >import "g" >>> >func Gi g.G(int) // declare alias >>> >func f() { >>> > Gi(1) >>> >} >>> > >>> >-- >>> >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 [3]golang-nuts...@googlegroups.com. >>> >For more options, visit [4]https://groups.google.com/d/optout. >>> > >>> >-- >>> >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 [5]golang-nuts...@googlegroups.com. >>> >For more options, visit [6]https://groups.google.com/d/optout. >>> > >>> > References >>> > >>> >Visible links >>> >1. mailto:axel.wa...@googlemail.com >>> >2. mailto:li...@networkimprov.net >>> >3. mailto:golang-nuts...@googlegroups.com >>> >4. https://groups.google.com/d/optout >>> >5. mailto:golang-nuts...@googlegroups.com >>> >6. https://groups.google.com/d/optout >>> >> -- >> 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. >> For more options, visit https://groups.google.com/d/optout. >> > -- 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/9dfb44a1-478a-4018-b8eb-b7df40013e70n%40googlegroups.com.
Re: [go-nuts] error types/strings and errors.Is
On Mon, Sep 28, 2020 at 3:46 AM Kevin Chadwick wrote: > > Are there any thoughts on how to handle error types. Will the user create > custom > error types from strings for use with errors.Is like for their own code or are > some error strings in the stdlib likely to change. In which case an "import > errors/types" managed by the stdlib might make sense? > > proposal: Go 2 error values > > https://github.com/golang/go/issues/29934#issuecomment-546896170 I don't think there is any one solution that will be used in all cases. Where the standard library can reasonably provide a shared error type, it should, as it already does for types like os.PathError and os.SyscallError. For a user package, whether it returns a specific error type is part of that package's API. Often there is no need for special error types for a user package. Where there is a need, the error types should be documented like any other part of the API. 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 golang-nuts+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/golang-nuts/CAOyqgcUHw0uLfDwDYzv8E7%3DCKhjz%2BX_sB8r0UmWg%3DSTaNj6wiw%40mail.gmail.com.
Re: [go-nuts] embedding
Thanks ! poniedziałek, 28 września 2020 o 19:00:10 UTC+2 bbse...@gmail.com napisał(a): > On Mon, Sep 28, 2020 at 10:55 AM Michał Pawełek > wrote: > > > > https://play.golang.org/p/CBuzITRmTiP > > > > Why isn't T1 allowed to pass to f ? > > func f requires an argument of type T. You cannot pass a value of type > T1. However, T1 has T embedded in it, so you can pass: > > f(t1.T) > > > > > > -- > > 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/76a2daf6-8b37-4b55-bfc0-c6621551e464n%40googlegroups.com > . > -- 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/3c9c07ec-1dfa-4bd8-90fa-d3a95598ba86n%40googlegroups.com.
Re: [go-nuts] embedding
On Mon, Sep 28, 2020 at 10:55 AM Michał Pawełek wrote: > > https://play.golang.org/p/CBuzITRmTiP > > Why isn't T1 allowed to pass to f ? func f requires an argument of type T. You cannot pass a value of type T1. However, T1 has T embedded in it, so you can pass: f(t1.T) > > -- > 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/76a2daf6-8b37-4b55-bfc0-c6621551e464n%40googlegroups.com. -- 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/CAMV2Rqpbphxh2Ev%2B%2BhAHWkQz5e4Uhaq0h2s3gkJDEc5t1pQs7g%40mail.gmail.com.
[go-nuts] embedding
https://play.golang.org/p/CBuzITRmTiP Why isn't T1 allowed to pass to f ? -- 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/76a2daf6-8b37-4b55-bfc0-c6621551e464n%40googlegroups.com.
[go-nuts] http server unable to authorize other CA authorities on windows
Team, Hi all, hope you're doing well. I have hosted a small api on windows 10 machine which I'm using as a webhook receiver. The CA authority of webhook sender is different from the CA authority of the golang api. Code of API is:- --- func main() { caCertPool := x509.NewCertPool() caCert2, _ := ioutil.ReadFile(" .pem ") caCertPool.AppendCertsFromPEM(caCert2) tlsConfig := &tls.Config{ RootCAs:caCertPool, InsecureSkipVerify: false,//tried with true and false both ClientCAs: caCertPool, //tried by giving and removing this property as well. } tlsConfig.BuildNameToCertificate() srv := &http.Server{Addr: ":443", TLSConfig: tlsConfig, Handler: http.HandlerFunc(handle)} log.Fatal(srv.ListenAndServeTLS("certificate.crt", "certificate.key")) } func handle(w http.ResponseWriter, r *http.Request) { // Log the request protocol log.Printf("Got connection: %s", r.Proto) // Send a message back to the client w.Write([]byte("Hello")) } -- *".pem" * :- this has the chain of all CA including webhook sender *"certificate.crt "* :- this certificate has complete root chain of other CA Still whenever I'm trying to make a call from webhook sender(github) to my api a tls handshake error occurs. Error at webhook sender side:- *Peer certificate cannot be authenticated with given CA certificates webhook* Error at webhook receiver side:- *TLS handshake error* The moment I've used another certificate in the method *ListenAndServeTLS, *created with the CA authority same as that of webhook sender, everything worked fine. In production, we're not allowed to make any certificate in that CA. Can anyone suggest me the procedure of trusting other CA's in case of windows machines with golang. -- 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/5e0c5369-6f1f-42ce-819b-514ca9c4216bn%40googlegroups.com.
Re: [go-nuts] EC crypto: Equivalent of EC_POINT_invert() in go?
On Fri, Sep 25, 2020 at 3:01 PM Anatol Pomozov wrote: > Or more precisely it calls this code https://boringssl.googlesource.com/boringssl/+/master/crypto/fipsmodule/ec/felem.c#57 > > But I want to avoid implementing parts of EC encryption myself and looking for a standard Golang way to achieve my goal. > > Shouldn't this inversion operation be part of the standard library? > My understanding is that the Go standard library prefers that the entire underlying logic of ECC should be hidden from the user, like in "crypto/ed25519". However, they can't get rid of elliptic.CryptoParams due to compatibility. It's not a good idea in a general sense to use CryptoParams because it uses big.Int which is not side-channel resistant. For these reasons I don't think it's likely they'all add point inversion. If you do want to go on... you can "invert" a point ("negate" would be a better term...) by simply setting y = n - y, for example: y := new(big.Int).Sub(curveParams.Params().N, y) Best regards, Conrado -- 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/CAHTptW8aoYGPhvR5QGo5M1wyJoSw1s8F2c_oasnsX%2BO%3Dc%2By3%2BA%40mail.gmail.com.
[go-nuts] error types/strings and errors.Is
Are there any thoughts on how to handle error types. Will the user create custom error types from strings for use with errors.Is like for their own code or are some error strings in the stdlib likely to change. In which case an "import errors/types" managed by the stdlib might make sense? proposal: Go 2 error values https://github.com/golang/go/issues/29934#issuecomment-546896170 -- 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/ebb5c380-2c55-c198-d3a8-013852b91e9f%40gmail.com.