[go-nuts] Re: ping binding to interface

2018-12-11 Thread Christian Joergensen
Check out:

- https://godoc.org/golang.org/x/net/icmp
- https://godoc.org/golang.org/x/net/ipv4
- https://godoc.org/golang.org/x/net/ipv6

Cheers,

Christian


On Tuesday, December 11, 2018 at 9:02:02 AM UTC+1, Naveen Neelakanta wrote:
>
> Hi All, 
>
> I have an application in golang, which requires me to bind to interface 
> and send ping request. 
>
> Any help would be appreciated 
>
> Thanks
> Naveen 
>

-- 
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://groups.google.com/d/optout.


[go-nuts] Re: X509 pem RSA example?

2018-02-01 Thread Christian Joergensen
The public key is contained in the private key. Which can be decoded using 
encoding/pem and crypto/x509.

Here's an example:
https://gist.github.com/chrj/1d25c18882b33e78d5882fb1fd8bf693

Cheers,

Christian

-- 
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://groups.google.com/d/optout.


[go-nuts] Re: Best way to launch/monitor several go process in production

2017-09-04 Thread Christian Joergensen
On Sunday, September 3, 2017 at 11:35:30 PM UTC+2, emarti...@gmail.com 
wrote:
>
> I am looking for the 'best' way to launch and monitor several go 
> processes. Doing it with just 1 is easy enough, using monit or systemctl 
> should do the trick, however since our app takes a while to start, we want 
> to keep a few proceses running at all times so we don't have downtime 
> everytime the app needs to be restarted. Similar to how apache sub proceses 
> works. One of the solutions we are thinking is to create a go launcher that 
> will spawn sub processes and using systemctl on that launcher.
>

How are users interacting with your program? If it is network-based you 
could just run multiple instances of your process with a load balancer in 
front. Either software (haproxy, nginx) or an (often expensive) hardware 
solution. Most cloud providers even have options for running hosted load 
balancers.

Then it is just a matter of doing a rolling upgrade and restart your 
processes one by one and the load balancer will route around the 
unavailable processes.

Cheers,

Christian

-- 
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://groups.google.com/d/optout.


[go-nuts] Re: database/sql - prepared select statements only work on first invocation

2017-08-28 Thread Christian Joergensen
On Monday, August 28, 2017 at 3:52:54 PM UTC+2, Ain wrote:
>
> Does anyone use prepared select statements sucessfully? With which 
> DB/driver?
> I'm sure that if my code is silly someone would have pointed it out so I'm 
> wondering am I the only one trying to use prepared select statements...
>

Have you seen the last comment on:
https://godoc.org/database/sql#Tx.Prepare

It looks like you're missing the call to:
https://godoc.org/database/sql#Tx.Stmt

Cheers,

Christian 

-- 
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://groups.google.com/d/optout.


Re: [go-nuts] Built-in log Package

2017-08-17 Thread Christian Joergensen
On Thursday, August 17, 2017 at 11:40:08 AM UTC+2, dc0d wrote:
>
> That's a nice package with good design (and I've used it for a while). But 
> I loose the info about where the error is happening.
>

What do you mean by where the error is happening?

Have you checked 
out 
http://godoc.org/github.com/pkg/errors#hdr-Retrieving_the_stack_trace_of_an_error_or_wrapper
 

Cheers,

Christian

-- 
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://groups.google.com/d/optout.


Re: [go-nuts] Re: HTTP/2 multiplexing

2017-08-03 Thread Christian Joergensen
On Thursday, August 3, 2017 at 11:07:50 AM UTC+2, pala.d...@gmail.com wrote:
>
> Example code with DuckDuckGo as default target:
>
> https://play.golang.org/p/_iI5-MDJ5t
>

This looks like a thundering herd race on connection setup. So there is no 
connection to reuse as none of them has been setup yet.

Try completing a single request and then run the rest of the requests in 
parallel afterwards.

Cheers,

Christian

-- 
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://groups.google.com/d/optout.


[go-nuts] Re: Reading Json file from s3 and want to keep all values in-memory structure.

2017-03-28 Thread Christian Joergensen
On Tuesday, March 28, 2017 at 12:23:02 PM UTC+2, Christian Joergensen wrote:
>
> Take a look at his function:
> https://godoc.org/github.com/aws/aws-sdk-go/service/s3#GetObjectOutput 
>

Correction; I meant this function:
https://godoc.org/github.com/aws/aws-sdk-go/service/s3#S3.GetObject

Cheers,

Christian

-- 
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://groups.google.com/d/optout.


[go-nuts] Re: Reading Json file from s3 and want to keep all values in-memory structure.

2017-03-28 Thread Christian Joergensen
On Monday, March 27, 2017 at 9:17:05 PM UTC+2, hunt wrote:
>
> Just wanted to know how can i achieve this.
>

What did you try?

Take a look at his function:
https://godoc.org/github.com/aws/aws-sdk-go/service/s3#GetObjectOutput 

The Body attribute of the resulting GetObjectOutput struct can be passed to 
json.NewDecoder:
https://godoc.org/encoding/json#NewDecoder

This will stream the data directly from S3 to the json decoder and your 
data shouldn't hit the disk.

Cheers,

Christian

-- 
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://groups.google.com/d/optout.


[go-nuts] Re: After conn.Close, connections is still alive

2017-03-07 Thread Christian Joergensen
On Tuesday, March 7, 2017 at 2:32:50 PM UTC+1, 倪彦春 wrote:
>
> I don't understand why the connection at clinet side is not closed after 
> `c.Close()` ?
>

When do you expect c.Close() to be called? Is it called then?

Cheers,

Christian 

-- 
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://groups.google.com/d/optout.


[go-nuts] Re: h2_bundle.go:3354: http2: server: error reading preface from client xx.xxx.xxx.128:43429: remote error: tls: revoked certificate

2017-03-03 Thread Christian Joergensen


On Friday, March 3, 2017 at 2:30:52 PM UTC+1, KLR wrote:
>
> The latest Firefox (51) produces this, FF 47 and Chrome work fine. 
> Start.com certificate. 
>
> export GODEBUG=http2client=0
> export GODEBUG=http2server=0
>
> eliminates the 'reading preface' error but the Código de error: 
> SEC_ERROR_REVOKED_CERTIFICATE persists.
>

You need to buy yourself a new certificate from a proper issuer. Check out:
https://security.googleblog.com/2016/10/distrusting-wosign-and-startcom.html

Cheers,

Christian
 

-- 
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://groups.google.com/d/optout.


[go-nuts] Re: [ANN] chasquid: An SMTP (email) server written in Go

2017-03-03 Thread Christian Joergensen
Nice work!

Have you considered "un-internalizing" some of your packages that could be 
useful outside your project?

The spf and systemd packages looks pretty useful.

Cheers,

Christian

-- 
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://groups.google.com/d/optout.


[go-nuts] Re: Serve large files

2017-02-28 Thread Christian Joergensen
Hello,

I'd recommend you take a look at:
https://godoc.org/net/http#ServeFile

This also gives you support for range requests and other goodies.

Cheers,

Christian

-- 
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://groups.google.com/d/optout.


[go-nuts] Re: How could the body for a func be "provided by runtime"?

2017-02-09 Thread Christian Joergensen
On Thursday, February 9, 2017 at 1:15:00 PM UTC+1, Sina Siadat wrote:
>
> But can't find how the compiler connects the two.
>

It's using the //go:linkname compiler directive:

https://github.com/golang/go/blob/master/src/runtime/panic.go#L583
https://golang.org/cmd/compile/ 

 Cheers,

Christian

-- 
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://groups.google.com/d/optout.


Re: [go-nuts] enforce go source pretty printing

2017-01-07 Thread Christian Joergensen
On Friday, January 6, 2017 at 9:14:08 PM UTC+1, mhh...@gmail.com wrote:
>
> yeah, but this output of go/format.Print really hurts me bad,
>

Does everything really have to go directly in the initialization of your 
map? How about just going with something like this:

https://play.golang.org/p/vqmzMzrMWz

Cheers,

Christian

>

-- 
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://groups.google.com/d/optout.


[go-nuts] Re: Not able to pass Bearer token in headers of a GET request in Golang

2016-10-31 Thread Christian Joergensen
Hi,

Have you tried inspecting the network traffic? Does the request contain the 
extra header?

What's urlfetch?

Cheers,


On Monday, October 31, 2016 at 1:35:00 PM UTC+1, Tahir Rauf wrote:
>
> I am using oauth2 to access a third party API. I can get the access token 
> alright, but when I try to call the API by passing the bearer token in the 
> request headers it gives me 401 (Unauthorized) error.  Although it works 
> well when I try to do it via POSTMAN by passing headers as  (Authorization: 
> Bearer ). But it does not work using go.
>
>
> Here is the code sample.
>
>
> url := "http://api.kounta.com/v1/companies/me.json;
>
>
> var bearer = "Bearer " + 
>
>
> req, err := http.NewRequest("GET", url, nil)
>
> req.Header.Add("authorization", bearer)
>
>
> client := urlfetch.Client(context)
>
>
> resp, err := client.Do(req)
>
> if err != nil {
>
> panic(err)
>
> }
>
> defer resp.Body.Close()
>
>
> body, _ := ioutil.ReadAll(resp.Body)
>
> writer.Write([]byte(body)) // Gives 401 Unauthorized error, though same 
> works using POSTMAN
>

-- 
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://groups.google.com/d/optout.


[go-nuts] Re: Namespacing hack using method on empty type

2016-08-05 Thread Christian Joergensen
Hi,

For starters, packages can't implement interfaces.

Cheers,

On Friday, August 5, 2016 at 6:19:31 AM UTC+2, Christoph Berger wrote:
>
> Are there any advantages over using real packages?

-- 
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://groups.google.com/d/optout.