Re: [go-nuts] error types/strings and errors.Is

2020-09-29 Thread 'Axel Wagner' via golang-nuts
On Tue, Sep 29, 2020 at 5:37 PM Kevin Chadwick  wrote:

> Is ENETUNREACH - "network is unreachable" typed anywhere? I assume string
> matching on these is part of the Go 1 promise?
>

I hope not. If you want to handle a specific error, what you should do is
file an issue to expose that error as a type (and thus make it part of the
API of the package), not to match strings - precisely *because* they aren't
part of the stable API, if they are not exposed, so shouldn't be relied on.

For your specific case, have you tried `errors.Is(err,
syscall.Errno(syscall.ENETUNREACH))`?


>
> --
> 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/1f29dfd6-2f41-ac84-6ee8-c9ff0d4bf917%40gmail.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/CAEkBMfHbUACkrz0GVZDjftadPR2CqB%3DA3N%3D%2BRtH7NfJA8U3SFg%40mail.gmail.com.


Re: [go-nuts] error types/strings and errors.Is

2020-09-29 Thread Kevin Chadwick
On 2020-09-28 23:28, Ian Lance Taylor wrote:
> 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

Is ENETUNREACH - "network is unreachable" typed anywhere? I assume string
matching on these is part of the Go 1 promise?

-- 
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/1f29dfd6-2f41-ac84-6ee8-c9ff0d4bf917%40gmail.com.


Re: [go-nuts] Re: syscall/js: JS Module Dynamic Imports?

2020-09-29 Thread Joop Kiefte
I think that's pretty recent? The only way used to be to add a script tag, and 
I have used that in Go before. I think just putting it in as a function call 
might work though...

[Joop Kiefte - Chat @ 
Spike](https://spikenow.com/r/a/?ref=spike-organic-signature&_ts=pengd)   
[pengd]

On September 29, 2020 at 12:55 GMT, Eduard Castany  
wrote:

I guess this works on node.js but I was referring to the browser environment. 
Where normal JavaScript can just `import("module")`.

On Tuesday, 29 September 2020 at 11:44:56 UTC+2 Alvadron wrote:

This is what I have been doing and it has worked for my needs:
```
// Importing it using "require" and storing the module in a variable
core := js.Global().Call("require", "@boostercloud/framework-core")

// Now get some props/methods from that module as usual:
config := core.Get("Booster").Get("config")
```
Is this what you were asking about?

El martes, 29 de septiembre de 2020 a las 9:13:03 UTC+1, eduard@gmail.com 
escribió:

In JavaScript we can 
[import](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/import)
 JavaScript modules statically and dynamically. How could we import a 
JavaScript module dynamically in Go?

The closest/simplest thing may be to add an HTML script tag into the page 
header programatically (and I'm going to try that) but maybe there is a more 
obvious way that I'm not seeing.

--
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/7a8c0562-ec87-47ae-a37e-207ca8a11483n%40googlegroups.com](https://groups.google.com/d/msgid/golang-nuts/7a8c0562-ec87-47ae-a37e-207ca8a11483n%40googlegroups.com?utm_medium=email&utm_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/c-64693-kfo28wdx-8glhrh%3Drdnx29%402.gethop.com.


[go-nuts] Re: syscall/js: JS Module Dynamic Imports?

2020-09-29 Thread Eduard Castany
I guess this works on node.js but I was referring to the browser 
environment. Where normal JavaScript can just `import("module")`.

On Tuesday, 29 September 2020 at 11:44:56 UTC+2 Alvadron wrote:

> This is what I have been doing and it has worked for my needs:
> ```
> // Importing it using "require" and storing the module in a variable
> core := js.Global().Call("require", "@boostercloud/framework-core")
>
> // Now get some props/methods from that module as usual:
> config := core.Get("Booster").Get("config")
> ```
> Is this what you were asking about?
>
> El martes, 29 de septiembre de 2020 a las 9:13:03 UTC+1, 
> eduard@gmail.com escribió:
>
>> In JavaScript we can import 
>> 
>>  
>> JavaScript modules statically and dynamically. How could we import a 
>> JavaScript module dynamically in Go?
>>
>> The closest/simplest thing may be to add an HTML script tag into the page 
>> header programatically (and I'm going to try that) but maybe there is a 
>> more obvious way that I'm not seeing.
>>
>

-- 
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/7a8c0562-ec87-47ae-a37e-207ca8a11483n%40googlegroups.com.


[go-nuts] Re: http server unable to authorize other CA authorities on windows

2020-09-29 Thread smartaq...@gmail.com
Hello,

The issue is resolved. 

Golang automatically search the CA's at appropriate path 

 in case of unix flavored machines 
But, in case of os esp. windows I don't find any possibility or doc for 
guiding a process to trust mmc based CA's. We just have to merge the certs 
like this:

-BEGIN CERTIFICATE- 
YOUR CERT 
YOUR CERT 
YOUR CERT 
-END CERTIFICATE- 
-BEGIN CERTIFICATE- 
SOME INTERMEDIATE CERT 
SOME INTERMEDIATE CERT 
SOME INTERMEDIATE CERT 
-END CERTIFICATE- 
-BEGIN CERTIFICATE- 
ANOTHER INTERMEDIATE CERT 
ANOTHER INTERMEDIATE CERT 
ANOTHER INTERMEDIATE CERT 
ANOTHER INTERMEDIATE CERT 
-END CERTIFICATE-  

 and use it as single one with this method(there are other ways also 
available).


ListenAndServeTLS()   
`
For more details check these articles:
http.ListenAndServeTLS with multiple certificates 

How to provide CA certs for ListenAndServeTLS function 


On Monday, 28 September 2020 at 19:30:40 UTC+5:30 smartaq...@gmail.com 
wrote:

> 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/d89c1a25-c341-49eb-92fb-551cab8fa3c1n%40googlegroups.com.


[go-nuts] Re: syscall/js: JS Module Dynamic Imports?

2020-09-29 Thread Alvadron
This is what I have been doing and it has worked for my needs:
```
// Importing it using "require" and storing the module in a variable
core := js.Global().Call("require", "@boostercloud/framework-core")

// Now get some props/methods from that module as usual:
config := core.Get("Booster").Get("config")
```
Is this what you were asking about?

El martes, 29 de septiembre de 2020 a las 9:13:03 UTC+1, 
eduard@gmail.com escribió:

> In JavaScript we can import 
> 
>  
> JavaScript modules statically and dynamically. How could we import a 
> JavaScript module dynamically in Go?
>
> The closest/simplest thing may be to add an HTML script tag into the page 
> header programatically (and I'm going to try that) but maybe there is a 
> more obvious way that I'm not seeing.
>

-- 
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/af259e26-67b2-495f-84a9-7af3c0afe763n%40googlegroups.com.


[go-nuts] syscall/js: JS Module Dynamic Imports?

2020-09-29 Thread Eduard Castany
In JavaScript we can import 

 
JavaScript modules statically and dynamically. How could we import a 
JavaScript module dynamically in Go?

The closest/simplest thing may be to add an HTML script tag into the page 
header programatically (and I'm going to try that) but maybe there is a 
more obvious way that I'm not seeing.

-- 
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/52d13816-09e5-4e17-941d-af343af0d770n%40googlegroups.com.


[go-nuts] protobuf avoid namespace conflict

2020-09-29 Thread Vasiliy Tolstov
Hi! I have two packages server and client. All belongs to different
repos. In this packages i have internal/errors dir with errors.proto
file
Both of them contains go_package option and package unique

option go_package = "xxx.org/server/internal/errors";
package server.errors;

option go_package = "xxx.org/client/internal/errors";
package client.errors;

why program that used client and server in the same time have such message

2020/09/29 10:50:18 WARNING: proto: file "errors.proto" is already registered
previously from: ""xxx.org/server/internal/errors"
currently from:  ""xxx.org/client/internal/errors"
A future release will panic on registration conflicts. See:
https://developers.google.com/protocol-buffers/docs/reference/go/faq#namespace-conflict

-- 
Vasiliy Tolstov,
e-mail: v.tols...@selfip.ru

-- 
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/CACaajQvUnd_2SY6_cR%3DcqwOeN2x8-Ze6b9vwOK5vv9HZtD%3Dr_Q%40mail.gmail.com.