[go-nuts] Re: C++ 11 to Golang convertor

2019-01-14 Thread Jason E. Aten
I came across this C to Go project. If you could revive the LLVM C output 
you could compile C++ to C with LLVM and then apply it.

https://github.com/elliotchance/c2go

It's rough/incomplete but it might give you something useful.

-- 
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] go1.12beta2 massively slower?

2019-01-14 Thread Jason E. Aten
Has anyone else tried the 1.12betas and found them painfully slow to 
compile with?

I think 1.12beta2 is faster than 1.12beta1, but it is still 2.8x slower 
than go1.10.7 on my machine.

I filed https://github.com/golang/go/issues/29743 with exact repro details.

-- 
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] performance optimization

2019-01-14 Thread Tamás Király
thanks for the suggestions and notes, i threw out the loop, save the start
timestamp and call time.Now()-start when i need the value which is in the
second range.

- Tamás

David Anderson  ezt írta (időpont: 2019. jan. 14., H,
21:54):

> Note that even for a state of the art CPU, there's only a few thousand
> instructions in a microsecond (1000 cycles per microsecond per GHz). At
> that kind of performance, anything you do that involves the OS or
> context-switching will make it impossible to hit your target refresh rate.
> The closest you can get is to lock the goroutine to an OS thread and do
> busy waiting (and that still won't save you from OS preemption, unless
> you're doing something explicit about that too).
>
> - Dave
>
> On Mon, Jan 14, 2019 at 12:35 PM Tamás Király  wrote:
>
>> I'm simulating the internal clock of an embedded microcontroller... And
>> this sentence (and you!) gave the idea to use time.Now().
>>
>> Thanks!
>> Tamas
>>
>> 9. jan. 14., H 21:12 dátummal Matt Ho  ezt írta:
>>
>>> Can you describe what task it is that needs to be updated every
>>> microsecond?  It seems like there should be a better to resolve the
>>> underlying need.
>>>
>>> M
>>>
>>> --
>>> 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.
>>>
>> --
>> 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.
>>
>

-- 
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] Transferring host's go-mod-download cache into docker container

2019-01-14 Thread Philip Nelson
You can't copy from outside the context but you can volume mount it. In my 
docker-compose.yml I have the following for a golang:1.11-alpine image 
derivative:

```
volumes:
  - ${GOPATH}:/go
```

Phil

I `RUN go mod download` before copying my source
On Monday, January 14, 2019 at 8:49:05 AM UTC-8, greg...@unity3d.com wrote:
>
> On Saturday, January 12, 2019 at 5:57:19 PM UTC-8, Sam Whited wrote:
>>
>> On Fri, Jan 11, 2019, at 23:03, greg...@unity3d.com wrote: 
>> > But now, I don't know how I can essentially copy the mod cache (or 
>> > whatever the right term is) like I'd have copied the vendor directory. 
>>
>> If you're suggesting that you already have the module cached on the 
>> machine that builds your containers, the cache lives at ~/go/pkg/mod by 
>> default so you could probably copy that tree into your build container. 
>>
>> —Sam 
>>
>
> Thanks for help, folks. As far as copying the `go env GOPATH`/pkg/mod from 
> the host to the docker container: I don't think I can copy from outside the 
> "context", which is the project repository. It's not horribly important; 
> this was more of an experiment for me to gain a bit more go.mod 
> understanding.  For now, I'm just going back to vendoring 'till some of 
> this shakes out a bit more.
>
>

-- 
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] What's the best way to detect if CGO is enabled?

2019-01-14 Thread Ian Lance Taylor
On Mon, Jan 14, 2019 at 3:26 PM  wrote:
>
> Whether CGO is enabled or not affects how reliable certain standard library 
> functions are. For example, os/user.LookupGroupId is untrustworthy if CGO is 
> not enabled (example 1, example 2).
>
> I can use build flags and two separate source files to determine whether CGO 
> is enabled or not, for example in this commit.
>
> This feels like it should be part of runtime, like runtime.GOOS and 
> runtime.GOARCH.
>
> Is there a better way to determine whether CGO is enabled?

Build tags are the best way.

Although it's true that the use of cgo affects of a few standard
library functions, it's not remotely as fundamental as GOOS and
GOARCH.  There is a way to check--via build tags--so I'm not sure we
need another mechanism.

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.
For more options, visit https://groups.google.com/d/optout.


[go-nuts] What's the best way to detect if CGO is enabled?

2019-01-14 Thread twpayne
Whether CGO is enabled or not affects how reliable certain standard library 
functions are. For example, os/user.LookupGroupId is untrustworthy if CGO 
is not enabled (example 1 , 
example 
2 ).

I can use build flags and two separate source files to determine whether 
CGO is enabled or not, for example in this commit 

.

This feels like it should be part of runtime, like runtime.GOOS and 
runtime.GOARCH.

Is there a better way to determine whether CGO is enabled?

Cheers,
Tom

-- 
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: Golang 1.11 Windows Support

2019-01-14 Thread peterGo
Discontinuation of support for Go and Windows XP and Vista has the usual 
meaning. If you encounter a problem, neither the Go team nor Microsoft will 
help. You are on your own.

Peter

On Monday, January 14, 2019 at 1:25:07 PM UTC-5, Subramanian Sridharan 
wrote:
>
> Hello Gophers!
>
> I read that Go 1.11 onwards, Windows XP and Vista aren't supported. 
> But when I cross compiled using GOOS and GOARCH, the exe file runs fine on 
> XP system.
> So does that mean the support for XP and Vista has been discontinued only 
> for development and compiled exes will run fine on them?
> Or is it unreliable to cross compile for such machines?
>
> TIA,
> Subramanian Sridharan.
>

-- 
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] performance optimization

2019-01-14 Thread David Anderson
Note that even for a state of the art CPU, there's only a few thousand
instructions in a microsecond (1000 cycles per microsecond per GHz). At
that kind of performance, anything you do that involves the OS or
context-switching will make it impossible to hit your target refresh rate.
The closest you can get is to lock the goroutine to an OS thread and do
busy waiting (and that still won't save you from OS preemption, unless
you're doing something explicit about that too).

- Dave

On Mon, Jan 14, 2019 at 12:35 PM Tamás Király  wrote:

> I'm simulating the internal clock of an embedded microcontroller... And
> this sentence (and you!) gave the idea to use time.Now().
>
> Thanks!
> Tamas
>
> 9. jan. 14., H 21:12 dátummal Matt Ho  ezt írta:
>
>> Can you describe what task it is that needs to be updated every
>> microsecond?  It seems like there should be a better to resolve the
>> underlying need.
>>
>> M
>>
>> --
>> 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.
>>
> --
> 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.
>

-- 
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] performance optimization

2019-01-14 Thread robert engels
If you are going to use time.Now() and a ‘change loop’, you should probably 
lock the thread to the Go routine to avoid an scheduler thrashing.

> On Jan 14, 2019, at 2:34 PM, Tamás Király  wrote:
> 
> I'm simulating the internal clock of an embedded microcontroller... And this 
> sentence (and you!) gave the idea to use time.Now().
> 
> Thanks!
> Tamas
> 
> 9. jan. 14., H 21:12 dátummal Matt Ho  > ezt írta:
> Can you describe what task it is that needs to be updated every microsecond?  
> It seems like there should be a better to resolve the underlying need.
> 
> M
> 
> 
> -- 
> 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 
> .
> 
> -- 
> 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 
> .

-- 
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] performance optimization

2019-01-14 Thread Tamás Király
I'm simulating the internal clock of an embedded microcontroller... And
this sentence (and you!) gave the idea to use time.Now().

Thanks!
Tamas

9. jan. 14., H 21:12 dátummal Matt Ho  ezt írta:

> Can you describe what task it is that needs to be updated every
> microsecond?  It seems like there should be a better to resolve the
> underlying need.
>
> M
>
> --
> 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.
>

-- 
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] How to increase concurrent users in net/http

2019-01-14 Thread Matt Ho
Would you mind also posting the network tuning parameters you're using 
along with the os?  I know that when I do perf testing for go on linux, I 
typically need to update a number of tcp related kernel parameters before I 
get meaningful numbers.

M

-- 
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] performance optimization

2019-01-14 Thread Matt Ho
Can you describe what task it is that needs to be updated every 
microsecond?  It seems like there should be a better to resolve the 
underlying need.

M

-- 
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] Golang 1.11 Windows Support

2019-01-14 Thread Jan Mercl
Not supported OS version means IMO: may not work at all as we're not
testing it and bugs specific to that OS version will get very low or zero
attention.

On Mon, Jan 14, 2019, 19:25 Subramanian Sridharan 
wrote:

> Hello Gophers!
>
> I read that Go 1.11 onwards, Windows XP and Vista aren't supported.
> But when I cross compiled using GOOS and GOARCH, the exe file runs fine on
> XP system.
> So does that mean the support for XP and Vista has been discontinued only
> for development and compiled exes will run fine on them?
> Or is it unreliable to cross compile for such machines?
>
> TIA,
> Subramanian Sridharan.
>
> --
> 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.
>
-- 

-j

-- 
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] Golang 1.11 Windows Support

2019-01-14 Thread Subramanian Sridharan
Hello Gophers!

I read that Go 1.11 onwards, Windows XP and Vista aren't supported. 
But when I cross compiled using GOOS and GOARCH, the exe file runs fine on 
XP system.
So does that mean the support for XP and Vista has been discontinued only 
for development and compiled exes will run fine on them?
Or is it unreliable to cross compile for such machines?

TIA,
Subramanian Sridharan.

-- 
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] Transferring host's go-mod-download cache into docker container

2019-01-14 Thread Michael Poindexter
Just as a data point, at my work we're using the `go mod vendor` / `go
build -mod=vendor` route for exactly the reasons you mention, and it works
quite well.

On Mon, Jan 14, 2019 at 8:49 AM  wrote:

> On Saturday, January 12, 2019 at 5:57:19 PM UTC-8, Sam Whited wrote:
>>
>> On Fri, Jan 11, 2019, at 23:03, greg...@unity3d.com wrote:
>> > But now, I don't know how I can essentially copy the mod cache (or
>> > whatever the right term is) like I'd have copied the vendor directory.
>>
>> If you're suggesting that you already have the module cached on the
>> machine that builds your containers, the cache lives at ~/go/pkg/mod by
>> default so you could probably copy that tree into your build container.
>>
>> —Sam
>>
>
> Thanks for help, folks. As far as copying the `go env GOPATH`/pkg/mod from
> the host to the docker container: I don't think I can copy from outside the
> "context", which is the project repository. It's not horribly important;
> this was more of an experiment for me to gain a bit more go.mod
> understanding.  For now, I'm just going back to vendoring 'till some of
> this shakes out a bit more.
>
> --
> 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.
>

-- 
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] Transferring host's go-mod-download cache into docker container

2019-01-14 Thread gregoryh
On Saturday, January 12, 2019 at 5:57:19 PM UTC-8, Sam Whited wrote:
>
> On Fri, Jan 11, 2019, at 23:03, greg...@unity3d.com  wrote: 
> > But now, I don't know how I can essentially copy the mod cache (or 
> > whatever the right term is) like I'd have copied the vendor directory. 
>
> If you're suggesting that you already have the module cached on the 
> machine that builds your containers, the cache lives at ~/go/pkg/mod by 
> default so you could probably copy that tree into your build container. 
>
> —Sam 
>

Thanks for help, folks. As far as copying the `go env GOPATH`/pkg/mod from 
the host to the docker container: I don't think I can copy from outside the 
"context", which is the project repository. It's not horribly important; 
this was more of an experiment for me to gain a bit more go.mod 
understanding.  For now, I'm just going back to vendoring 'till some of 
this shakes out a bit more.

-- 
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: Arrays

2019-01-14 Thread peterGo
John,

Here is a simple proof-of-concept implementation.

Playground: https://play.golang.org/p/Hd0dmazXI5v

Output:

11 12 13 14 
21 22 23 24 
31 32 33 34 

XX 12 13 14 
21 XX 23 24 
31 32 XX 34 


Peter

On Monday, January 14, 2019 at 12:47:50 AM UTC-5, John wrote:
>
> Dear Gophers,
> 
>   I am a beginner gopher has created a project of Connect Five. The 
> game's board is shown in a dot array like this
>
> ...
> ...
> ...
>  And to input, you have to put in the exact coordinates of the place 
> you want to place, like this 1 3. You would have to carefully count the 
> dots and then input, which is a pain for the eyes. So I wonder if it is 
> possible to make a array like this and how:
>  
>
> 11 12 13 14
> 21 22 23 24
> 31 32 33 34
>
>   
> 
>Thank you,
>
>   
> 
>  John
>

-- 
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] go/types: check if *ast.Ident is a function parameter

2019-01-14 Thread Pierre Durand
Hello !

I'm trying to write a tool that will:
- parse my code, and find variable assignment
- check if the assigned variable is a parameter in the current function (or 
a function parameter in the current scope)

func myFunc(a *A){
a.foo = "bar"
}

In the code above, I want to detect that "a" in "a.foo" is referencing the 
"a *A" parameter in my function.

I already know how to use ast.Walk(), and find the *ast.Ident for "a" in 
"a.foo".
I also know that I can use types.Info.Defs with conf.Check().

Can someone give me some advice please ?

-- 
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] what is the use of context in golang RESTful apis?

2019-01-14 Thread robert engels
I mostly concur - Go really needs TLS - simplifies this sort of thing. You can 
look at many “complex” Java based server systems and the method calls are far 
simpler in the common case (especially when using a framework that leverages 
TLS).

I think a key issue is that most ‘requests’ are not long-enough lived for the 
cancellation context to be warranted - otherwise the site would be too slow 
anyway. You see this need in “background jobs” - and still, these jobs are 
usually per server/application, not per user or per request.

Systems that perform time consuming data analysis jobs on behalf of a user are 
a different case, and they clearly need a way to stop their processing.

And yes the ‘not type safe api’ for values is a problem. If Go really wants to 
promote the context as ubiquitous it should have built-in language support to 
address these issues (type safety, no need for TLS, required at Go routine 
creation site, etc.).



> On Jan 13, 2019, at 6:35 PM, Space A.  wrote:
> 
> I just leave it here
> 
> Context should go away for Go 2 
> 
> 
> 
> 
> воскресенье, 13 января 2019 г., 22:21:50 UTC+3 пользователь Tamás Gulácsi 
> написал:
> -BEGIN PGP SIGNED MESSAGE- 
> Hash: SHA256 
> 
> There should be a "global" or parent Context, which is canceled when the 
> server is going to shut down (e.g. with signal.Notify), and each handler 
> should create a child context with a proper timeout. 
> 
> And it should watch the request's Context, too, as that's what will be 
> canceled when the client disconnects. github.com/LK4D4/joincontext 
>  may help with tis. 
> 
> But if you use the request's Context only with a propert timeout, that's 
> already better than doing nothing. 
> 
> Tamás 
> 
> 
> ‐‐‐ Original Message ‐‐‐ 
> On 2019. January 13., Sunday 19:49, Mahendra Bhoir > 
> wrote: 
> 
> > That makes sense.. So where should declare my context variable? Inside 
> > handler function or in main function As handler itself is a goroutine.. 
> > 
> > On Sun, Jan 13, 2019 at 11:24 PM Justin Israel > 
> > wrote: 
> > 
> > > On Mon, Jan 14, 2019, 2:23 AM Mahendra Bhoir > 
> > > wrote: 
> > > 
> > > > APIs I have written are for mobile applications and request 
> > > > cancellation doesn’t happen much on mobile applications. 
> > > 
> > > What if the mobile client closes the app in the middle of an expensive 
> > > request?  
> > > 
> > > > I think I am little confused with uses of context. 
> > > > 
> > > > I found this page on Internet about context. I this will clear my 
> > > > confusions.. 
> > > > 
> > > > https://www.sohamkamani.com/blog/golang/2018-06-17-golang-using-context-cancellation/#listening-for-the-cancellation-event
> > > >  
> > > > 
> > > >  
> > > > 
> > > > On Sun, 13 Jan 2019 at 6:24 PM, Tamás Gulácsi > 
> > > > wrote: 
> > > > 
> > > > > Timing out and cancellation are the main uses of Context. 
> > > > > 
> > > > > How do you cancel processing when the client clises the connection? 
> > > > > 
> > > > > -- 
> > > > > 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 
> > > > > . 
> > > > 
> > > > -- 
> > > > Mahendra Bhoir.  
> > > > +919545688916 
> > > > 
> > > > -- 
> > > > 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 
> > > > . 
> > 
> > -- 
> > Mahendra Bhoir.  
> > +919545688916 
> -BEGIN PGP SIGNATURE- 
> Version: ProtonMail 
> Comment: https://protonmail.com  
> 
> wsBcBAEBCAAGBQJcO4+hAAoJELj70Bsqr19tI9QIAIwrPJKrRlALTtOxnDY8 
> qoLippDAevQxpAzpQYW6w5VN7eDrxdXUrIH1gHGXYJPYOv/J7/i4gbK1txW0 
> rQaaKpR8JmCY6CDdaQaTVg50XeC3yApFJPEeRZazLztnmKi6HB6PQhgGondA 
> edpsPOQejfLe9KMhN+7RJzVjwWYHYwZXyMIITQT8/jADip3AAZWKojcXFpJq 
> 7MfWfIjru0+tT5+hSfLr8JZpimMwhmOoW8xVeTKmZkXonucky5E3WmJUEPEv 
> 3lcQQVZI3827PLeMKsKd6UpI2x2CcCqLPInIeEzVsDjhWURI2gznWv2Sqj6v 
> T3wS3oVXoJo28sgb9ViyEC0= 
> =1E4l 
> -END PGP SIGNATURE- 
> 
> 
> -- 
> 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 

[go-nuts] Re: Arrays

2019-01-14 Thread Yamil Bracho
It could be :
a := [3][4]string{"1 1", "1 2", "1 3", "1 4", "2 1", "2 2", "2 3", "2 4", 
"3 1", "3 2", "3 3", "3 4" } 

or

var a = [3][4]string

for (row = 0; row < 3; row++) {
   for (col = 0; col < 4; col++) {
   a[row][col] = fmt.Sprintf("%d %d", (row+1), (col+1)
   }
}   

El lunes, 14 de enero de 2019, 0:47:50 (UTC-5), John escribió:
>
> Dear Gophers,
> 
>   I am a beginner gopher has created a project of Connect Five. The 
> game's board is shown in a dot array like this
>
> ...
> ...
> ...
>  And to input, you have to put in the exact coordinates of the place 
> you want to place, like this 1 3. You would have to carefully count the 
> dots and then input, which is a pain for the eyes. So I wonder if it is 
> possible to make a array like this and how:
>  
>
> 11 12 13 14
> 21 22 23 24
> 31 32 33 34
>
>   
> 
>Thank you,
>
>   
> 
>  John
>

-- 
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: binary protocols code generators (parser/writer/validator/[de]serializer)

2019-01-14 Thread Robert Engels
He stated that protobufs would only be 50% for existing formats... no need to 
pounce. 

On Jan 14, 2019, at 4:04 AM, Dmitry Ponyatov  wrote:

>> Protocol Buffers springs to mind.
> 
> Totally wrong. Protocol Buffers unable to parse TIFF or STEP file.
>  
> -- 
> 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.

-- 
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] How to increase concurrent users in net/http

2019-01-14 Thread Kasun Vithanage
Sure, will post when i do it. Will open a new thread then :)

On Monday, January 14, 2019 at 7:49:36 PM UTC+5:30, Rodolfo Azevedo wrote:
>
> Please, when you finish your workerpool can you share your code to me? I 
> need to understand this.
>
> Thanks and Regards
>
> Rodolfo Azevedo
>
> Em seg, 14 de jan de 2019 às 10:16, Kasun Vithanage  > escreveu:
>
>> I've deleted original post because it seems a problem with my code, will 
>> try to use a WorkerPool and see the result :) 
>> Thanks for support
>>
>> On Monday, January 14, 2019 at 6:38:27 PM UTC+5:30, Jesper Louis Andersen 
>> wrote:
>>>
>>> This might not be due to Go, but rather due to a resource limit imposed 
>>> by the operating system:
>>>
>>> # 5000. *. (1. -. 0.1954);;
>>> - : float = 4023.
>>>
>>> This is close to 4096, assuming a constant factor of other stuff needing 
>>> resources. Also, as a first step, I'd recommend running your load generator 
>>> on a host separate from the system under test. There are situations in 
>>> which your load generator takes enough resources to mess with the SUT.
>>>
>>> On Mon, Jan 14, 2019 at 12:48 PM Kasun Vithanage  
>>> wrote:
>>>
 I'm doing a simple load test with Apache JMeter. My ambition was to 
 benchmark a go server. Here is the code I've been using, its a simple web 
 server

 package main


 import (
  "fmt"
  "log"
  "net/http"
  "runtime"
 )


 func handler(w http.ResponseWriter, r *http.Request) {
  fmt.Fprintf(w, "welcome")
 }


 func main() {
  runtime.GOMAXPROCS(runtime.NumCPU())
  http.HandleFunc("/function", handler)
  log.Fatal(http.ListenAndServe(":8080", nil))
 }

 When i test the JMeter with 5000 users with Ramp Up Period 1s, Loop 
 Count 1 as stated below

 [image: Screenshot_27.png]

 The result is as follows, it has *around 20% error rate* for the HTTP 
 requests. 

 [image: Screenshot_28.png]

 When i examine the reason for an error JMeter states that the *Connection 
 was refused* by host.

 I would like to know how to increase concurrency in here, at least not 
 dropping the connections in that rate. If the server handler code was bit 
 complex than this, the error rate is increasing to at least 80%.

 I tried the same kind of scenario with Java NIO(
 *com.sun.net.httpserver*). It resulted better as it had a lower error 
 rate. But it caused a high latency when the work is done(Tested with same 
 load).

 -- 
 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.

>>>
>>>
>>> -- 
>>> J.
>>>
>> -- 
>> 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.
For more options, visit https://groups.google.com/d/optout.


Re: [go-nuts] How to increase concurrent users in net/http

2019-01-14 Thread Rodolfo
Please, when you finish your workerpool can you share your code to me? I
need to understand this.

Thanks and Regards

Rodolfo Azevedo

Em seg, 14 de jan de 2019 às 10:16, Kasun Vithanage 
escreveu:

> I've deleted original post because it seems a problem with my code, will
> try to use a WorkerPool and see the result :)
> Thanks for support
>
> On Monday, January 14, 2019 at 6:38:27 PM UTC+5:30, Jesper Louis Andersen
> wrote:
>>
>> This might not be due to Go, but rather due to a resource limit imposed
>> by the operating system:
>>
>> # 5000. *. (1. -. 0.1954);;
>> - : float = 4023.
>>
>> This is close to 4096, assuming a constant factor of other stuff needing
>> resources. Also, as a first step, I'd recommend running your load generator
>> on a host separate from the system under test. There are situations in
>> which your load generator takes enough resources to mess with the SUT.
>>
>> On Mon, Jan 14, 2019 at 12:48 PM Kasun Vithanage 
>> wrote:
>>
>>> I'm doing a simple load test with Apache JMeter. My ambition was to
>>> benchmark a go server. Here is the code I've been using, its a simple web
>>> server
>>>
>>> package main
>>>
>>>
>>> import (
>>>  "fmt"
>>>  "log"
>>>  "net/http"
>>>  "runtime"
>>> )
>>>
>>>
>>> func handler(w http.ResponseWriter, r *http.Request) {
>>>  fmt.Fprintf(w, "welcome")
>>> }
>>>
>>>
>>> func main() {
>>>  runtime.GOMAXPROCS(runtime.NumCPU())
>>>  http.HandleFunc("/function", handler)
>>>  log.Fatal(http.ListenAndServe(":8080", nil))
>>> }
>>>
>>> When i test the JMeter with 5000 users with Ramp Up Period 1s, Loop
>>> Count 1 as stated below
>>>
>>> [image: Screenshot_27.png]
>>>
>>> The result is as follows, it has *around 20% error rate* for the HTTP
>>> requests.
>>>
>>> [image: Screenshot_28.png]
>>>
>>> When i examine the reason for an error JMeter states that the *Connection
>>> was refused* by host.
>>>
>>> I would like to know how to increase concurrency in here, at least not
>>> dropping the connections in that rate. If the server handler code was bit
>>> complex than this, the error rate is increasing to at least 80%.
>>>
>>> I tried the same kind of scenario with Java NIO(*com.sun.net.httpserver*).
>>> It resulted better as it had a lower error rate. But it caused a high
>>> latency when the work is done(Tested with same load).
>>>
>>> --
>>> 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.
>>>
>>
>>
>> --
>> J.
>>
> --
> 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.
>

-- 
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] How to increase concurrent users in net/http

2019-01-14 Thread Kasun Vithanage
I've deleted original post because it seems a problem with my code, will 
try to use a WorkerPool and see the result :) 
Thanks for support

On Monday, January 14, 2019 at 6:38:27 PM UTC+5:30, Jesper Louis Andersen 
wrote:
>
> This might not be due to Go, but rather due to a resource limit imposed by 
> the operating system:
>
> # 5000. *. (1. -. 0.1954);;
> - : float = 4023.
>
> This is close to 4096, assuming a constant factor of other stuff needing 
> resources. Also, as a first step, I'd recommend running your load generator 
> on a host separate from the system under test. There are situations in 
> which your load generator takes enough resources to mess with the SUT.
>
> On Mon, Jan 14, 2019 at 12:48 PM Kasun Vithanage  > wrote:
>
>> I'm doing a simple load test with Apache JMeter. My ambition was to 
>> benchmark a go server. Here is the code I've been using, its a simple web 
>> server
>>
>> package main
>>
>>
>> import (
>>  "fmt"
>>  "log"
>>  "net/http"
>>  "runtime"
>> )
>>
>>
>> func handler(w http.ResponseWriter, r *http.Request) {
>>  fmt.Fprintf(w, "welcome")
>> }
>>
>>
>> func main() {
>>  runtime.GOMAXPROCS(runtime.NumCPU())
>>  http.HandleFunc("/function", handler)
>>  log.Fatal(http.ListenAndServe(":8080", nil))
>> }
>>
>> When i test the JMeter with 5000 users with Ramp Up Period 1s, Loop Count 
>> 1 as stated below
>>
>> [image: Screenshot_27.png]
>>
>> The result is as follows, it has *around 20% error rate* for the HTTP 
>> requests. 
>>
>> [image: Screenshot_28.png]
>>
>> When i examine the reason for an error JMeter states that the *Connection 
>> was refused* by host.
>>
>> I would like to know how to increase concurrency in here, at least not 
>> dropping the connections in that rate. If the server handler code was bit 
>> complex than this, the error rate is increasing to at least 80%.
>>
>> I tried the same kind of scenario with Java NIO(*com.sun.net.httpserver*). 
>> It resulted better as it had a lower error rate. But it caused a high 
>> latency when the work is done(Tested with same load).
>>
>> -- 
>> 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.
>>
>
>
> -- 
> J.
>

-- 
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] How to increase concurrent users in net/http

2019-01-14 Thread Kasun Vithanage
I would also try to test the load on a different host too.

On Monday, January 14, 2019 at 6:38:27 PM UTC+5:30, Jesper Louis Andersen 
wrote:
>
> This might not be due to Go, but rather due to a resource limit imposed by 
> the operating system:
>
> # 5000. *. (1. -. 0.1954);;
> - : float = 4023.
>
> This is close to 4096, assuming a constant factor of other stuff needing 
> resources. Also, as a first step, I'd recommend running your load generator 
> on a host separate from the system under test. There are situations in 
> which your load generator takes enough resources to mess with the SUT.
>
> On Mon, Jan 14, 2019 at 12:48 PM Kasun Vithanage  > wrote:
>
>> I'm doing a simple load test with Apache JMeter. My ambition was to 
>> benchmark a go server. Here is the code I've been using, its a simple web 
>> server
>>
>> package main
>>
>>
>> import (
>>  "fmt"
>>  "log"
>>  "net/http"
>>  "runtime"
>> )
>>
>>
>> func handler(w http.ResponseWriter, r *http.Request) {
>>  fmt.Fprintf(w, "welcome")
>> }
>>
>>
>> func main() {
>>  runtime.GOMAXPROCS(runtime.NumCPU())
>>  http.HandleFunc("/function", handler)
>>  log.Fatal(http.ListenAndServe(":8080", nil))
>> }
>>
>> When i test the JMeter with 5000 users with Ramp Up Period 1s, Loop Count 
>> 1 as stated below
>>
>> [image: Screenshot_27.png]
>>
>> The result is as follows, it has *around 20% error rate* for the HTTP 
>> requests. 
>>
>> [image: Screenshot_28.png]
>>
>> When i examine the reason for an error JMeter states that the *Connection 
>> was refused* by host.
>>
>> I would like to know how to increase concurrency in here, at least not 
>> dropping the connections in that rate. If the server handler code was bit 
>> complex than this, the error rate is increasing to at least 80%.
>>
>> I tried the same kind of scenario with Java NIO(*com.sun.net.httpserver*). 
>> It resulted better as it had a lower error rate. But it caused a high 
>> latency when the work is done(Tested with same load).
>>
>> -- 
>> 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.
>>
>
>
> -- 
> J.
>

-- 
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] How to increase concurrent users in net/http

2019-01-14 Thread Kasun Vithanage
I was wondering about it too, but I see Sun's HTTP Server can handle almost 
every request with even some work load under the same machine. It uses a 
ThreadPool for the task while go uses goroutines.

On Monday, January 14, 2019 at 6:38:27 PM UTC+5:30, Jesper Louis Andersen 
wrote:
>
> This might not be due to Go, but rather due to a resource limit imposed by 
> the operating system:
>
> # 5000. *. (1. -. 0.1954);;
> - : float = 4023.
>
> This is close to 4096, assuming a constant factor of other stuff needing 
> resources. Also, as a first step, I'd recommend running your load generator 
> on a host separate from the system under test. There are situations in 
> which your load generator takes enough resources to mess with the SUT.
>
> On Mon, Jan 14, 2019 at 12:48 PM Kasun Vithanage  > wrote:
>
>> I'm doing a simple load test with Apache JMeter. My ambition was to 
>> benchmark a go server. Here is the code I've been using, its a simple web 
>> server
>>
>> package main
>>
>>
>> import (
>>  "fmt"
>>  "log"
>>  "net/http"
>>  "runtime"
>> )
>>
>>
>> func handler(w http.ResponseWriter, r *http.Request) {
>>  fmt.Fprintf(w, "welcome")
>> }
>>
>>
>> func main() {
>>  runtime.GOMAXPROCS(runtime.NumCPU())
>>  http.HandleFunc("/function", handler)
>>  log.Fatal(http.ListenAndServe(":8080", nil))
>> }
>>
>> When i test the JMeter with 5000 users with Ramp Up Period 1s, Loop Count 
>> 1 as stated below
>>
>> [image: Screenshot_27.png]
>>
>> The result is as follows, it has *around 20% error rate* for the HTTP 
>> requests. 
>>
>> [image: Screenshot_28.png]
>>
>> When i examine the reason for an error JMeter states that the *Connection 
>> was refused* by host.
>>
>> I would like to know how to increase concurrency in here, at least not 
>> dropping the connections in that rate. If the server handler code was bit 
>> complex than this, the error rate is increasing to at least 80%.
>>
>> I tried the same kind of scenario with Java NIO(*com.sun.net.httpserver*). 
>> It resulted better as it had a lower error rate. But it caused a high 
>> latency when the work is done(Tested with same load).
>>
>> -- 
>> 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.
>>
>
>
> -- 
> J.
>

-- 
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] How to increase concurrent users in net/http

2019-01-14 Thread Jesper Louis Andersen
This might not be due to Go, but rather due to a resource limit imposed by
the operating system:

# 5000. *. (1. -. 0.1954);;
- : float = 4023.

This is close to 4096, assuming a constant factor of other stuff needing
resources. Also, as a first step, I'd recommend running your load generator
on a host separate from the system under test. There are situations in
which your load generator takes enough resources to mess with the SUT.

On Mon, Jan 14, 2019 at 12:48 PM Kasun Vithanage 
wrote:

> I'm doing a simple load test with Apache JMeter. My ambition was to
> benchmark a go server. Here is the code I've been using, its a simple web
> server
>
> package main
>
>
> import (
>  "fmt"
>  "log"
>  "net/http"
>  "runtime"
> )
>
>
> func handler(w http.ResponseWriter, r *http.Request) {
>  fmt.Fprintf(w, "welcome")
> }
>
>
> func main() {
>  runtime.GOMAXPROCS(runtime.NumCPU())
>  http.HandleFunc("/function", handler)
>  log.Fatal(http.ListenAndServe(":8080", nil))
> }
>
> When i test the JMeter with 5000 users with Ramp Up Period 1s, Loop Count
> 1 as stated below
>
> [image: Screenshot_27.png]
>
> The result is as follows, it has *around 20% error rate* for the HTTP
> requests.
>
> [image: Screenshot_28.png]
>
> When i examine the reason for an error JMeter states that the *Connection
> was refused* by host.
>
> I would like to know how to increase concurrency in here, at least not
> dropping the connections in that rate. If the server handler code was bit
> complex than this, the error rate is increasing to at least 80%.
>
> I tried the same kind of scenario with Java NIO(*com.sun.net.httpserver*).
> It resulted better as it had a lower error rate. But it caused a high
> latency when the work is done(Tested with same load).
>
> --
> 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.
>


-- 
J.

-- 
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] How to increase concurrent users in net/http

2019-01-14 Thread Kasun Vithanage
I'm doing a simple load test with Apache JMeter. My ambition was to 
benchmark a go server. Here is the code I've been using, its a simple web 
server

package main


import (
 "fmt"
 "log"
 "net/http"
 "runtime"
)


func handler(w http.ResponseWriter, r *http.Request) {
 fmt.Fprintf(w, "welcome")
}


func main() {
 runtime.GOMAXPROCS(runtime.NumCPU())
 http.HandleFunc("/function", handler)
 log.Fatal(http.ListenAndServe(":8080", nil))
}

When i test the JMeter with 5000 users with Ramp Up Period 1s, Loop Count 1 
as stated below

[image: Screenshot_27.png]

The result is as follows, it has *around 20% error rate* for the HTTP 
requests. 

[image: Screenshot_28.png]

When i examine the reason for an error JMeter states that the *Connection 
was refused* by host.

I would like to know how to increase concurrency in here, at least not 
dropping the connections in that rate. If the server handler code was bit 
complex than this, the error rate is increasing to at least 80%.

I tried the same kind of scenario with Java NIO(*com.sun.net.httpserver*). 
It resulted better as it had a lower error rate. But it caused a high 
latency when the work is done(Tested with same load).

-- 
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: binary protocols code generators (parser/writer/validator/[de]serializer)

2019-01-14 Thread Ronny Bangsund
Protocol Buffers springs to mind. It's a compact binary protocol with 
predefined field order, allowing you to skip unused fields and maintain 
backwards compatibility. You could probably use it as a storage format too. 
It's not in the Lex/Yacc territory, but it DOES generate all the code you 
need to handle the defined structures.

Protobuf is the message definition, and it goes hand in hand with gRPC to 
generate client code plus server code stubs for secure network 
communication with optional streaming:
https://developers.google.com/protocol-buffers/
https://grpc.io

If you're looking for tools for existing binary formats, I dunno. Protobuf 
would only be halfway there, as I don't think it supports unions with 
overlapping fields as you could find in some (like the PE binary format for 
Win32/Win64).

-- 
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.