Re: [go-nuts] Re: .net core vs go

2016-10-08 Thread Sotirios Mantziaris
Hi,

i too use go and i see all the benefits that you are mentioning. I was only 
pointing out what was wrong in the post about windows...

BTW You don't need IIS to run .Net Core. There is a new web server named 
Kestrel (check this video https://vimeo.com/172009499) which performs very 
well.
So creating docker containers is straightforward too. You just need more 
files to deploy instead of one and if you automated this it should not 
matter!

BTW There is a project research named .Net Native which will eventually 
create on static linked binary!!!

I do not have any idea about memory consumption on .net core., this would 
be nice to check out! Comparing ruby with go is a little off, since ruby is 
not known to be performant and cheap on memory.

Creating apps with both is very nice. go gives you what you have mentioned. 
.net core almost the same with better tooling (Visual Studio rocks)

On Saturday, October 8, 2016 at 9:25:27 AM UTC+3, francoi...@gmail.com 
wrote:
>
> Hi Sotirios
>
> I have always been someone trying to balance out the "developer 
> productivity" vs "runtime efficiency". By only using a coding 
> language/framework because you can code much quicker in it is almost 99% of 
> the time going to bite you in the *** later. Sure if you just want to 
> "prototype" something it doesn't matter. But how often does the prototype 
> not become the starting point and turn into the "legacy" black-box nobody 
> want to touch.
>
> Consider for instance something like Gitlab written in Ruby vs Gogs (with 
> Drone CI) both written in golang.
>
> Gitlab requires about 2GB Memory (minimum) to run in production with as 
> little as 10 users. If you have less than that Gitlab will feel really, 
> really slow and even sometimes run into "out of memory" errors.
>
> Now Gogs on the other side uses about 20MB of memory. Sure, Gitlab is at 
> this point more mature than Gogs but is it sustainable? Consider having to 
> host these two on DigitalOcean for example. You will need at least the 2GB 
> Droplet for Gitlab whereas the 512MB Droplet will be more than sufficient 
> for Gogs. You can even turn it up a notch. If you want to host 20 instances 
> of Gitlab or Gogs. For Gitlab you will need 20 of the 2GB Droplets, adding 
> up to $400/month. But for gogs the SINGLE 512MB will still be sufficient at 
> $5/month.
>
> Now that is enough on the Memory side. Golang can be built as a "static 
> binary" which means the SINGLE binary file contains everything about the 
> the application. Consider this article: 
> https://blog.codeship.com/building-minimal-docker-containers-for-go-applications/,
>  
> where the static linked binary is a mere 5.6MB in size. If you take .NET 
> you will probably need IIS and the .NET Framework on top of your 
> application.
>
> Golang also actually include the http server in this 5.6MB of static 
> binary. So no need for another layer like IIS.
>
> Just a handy tip. There are "awesome lists" of about any framework and 
> language out there:
>
>- Curated list of them all: https://github.com/sindresorhus/awesome
>- Golang: https://github.com/avelino/awesome-go and 
>https://github.com/golang/go/wiki/Projects 
>- .NET Core: https://github.com/thangchung/awesome-dotnet-core
>
>
>
>
> On Wednesday, 18 May 2016 16:06:30 UTC+2, Sotirios Mantziaris wrote:
>>
>> Dear Tim,
>>
>> We are a .Net house and we are running "windows services" for months 
>> without having any problem. Sql Server, which is a very robust RDBMS, is a 
>> windows service and runs rock solid for years. So the issues you mentioned 
>> are mainly your own code issues.
>>
>> Windows has a feature called Task Scheduler where you can schedule 
>> anything to run on a schedule if that is what you want.
>>
>> The claim that .Net is not heavily concurrent is not true either. You can 
>> use TPL (Task Parallel Library) and run a really solid and performant 
>> concurrent programming model with ease. 
>> This will scale very nicely with the cores of your machine. Especially 
>> when using Parallel.For which does some optimizations.
>>
>> Long story short. Please try to be correct on your claims since you are 
>> sounding like you don't know windows and .net that much. no harm intended. 
>>
>> Kind regards
>>
>> On Wednesday, May 18, 2016 at 5:09:13 AM UTC+3, Tim Hawkins wrote:
>>>
>>> He mentions that they have a bunch of Web scrappers,  this kind of task 
>>> is heavily concurrent, something that .net is not know for, but golang is. 
>>> We are a php house, but we are switching to go for this one reason, our new 
>>> internal stack wil be based on php frontend,  golang based microservices 
>>> layers, and mysql, elasticsearch and mongo based data stores. 
>>>
>>> We also run Windows and Linux servers,  we are continually having 
>>> problems with our windows systems stalling becuase the predominate pattern 
>>> for services there is to build a "windows service",  which suffers from 
>>> issues with leakage of resource

Re: [go-nuts] Re: .net core vs go

2016-10-08 Thread Jan Mercl
On Wed, May 18, 2016 at 4:06 PM Sotirios Mantziaris 
wrote:

> The claim that .Net is not heavily concurrent is not true either.

A Go program executing 100k goroutines needs 200MB or 400MB RAM for stack,
depending on version, so it can run just fine. A .net program trying to
execute 100k threads will OOM way before reaching a even a small fraction
of the goal.

-- 

-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] Re: .net core vs go

2016-10-08 Thread Francois Hill
Hi, yes I agree with the fact that Visual Studio is one of the best IDE's
out there. But in general tooling, golang has a great set too. I suggest
you check out VS Code with golang extension, pretty neat! And on top of
that VS Code is cross-platform too.



On Sat, 8 Oct 2016, 09:15 Sotirios Mantziaris, 
wrote:

> Hi,
>
> i too use go and i see all the benefits that you are mentioning. I was
> only pointing out what was wrong in the post about windows...
>
> BTW You don't need IIS to run .Net Core. There is a new web server named
> Kestrel (check this video https://vimeo.com/172009499) which performs
> very well.
> So creating docker containers is straightforward too. You just need more
> files to deploy instead of one and if you automated this it should not
> matter!
>
> BTW There is a project research named .Net Native which will eventually
> create on static linked binary!!!
>
> I do not have any idea about memory consumption on .net core., this would
> be nice to check out! Comparing ruby with go is a little off, since ruby is
> not known to be performant and cheap on memory.
>
> Creating apps with both is very nice. go gives you what you have
> mentioned. .net core almost the same with better tooling (Visual Studio
> rocks)
>
>
> On Saturday, October 8, 2016 at 9:25:27 AM UTC+3, francoi...@gmail.com
> wrote:
>
> Hi Sotirios
>
> I have always been someone trying to balance out the "developer
> productivity" vs "runtime efficiency". By only using a coding
> language/framework because you can code much quicker in it is almost 99% of
> the time going to bite you in the *** later. Sure if you just want to
> "prototype" something it doesn't matter. But how often does the prototype
> not become the starting point and turn into the "legacy" black-box nobody
> want to touch.
>
> Consider for instance something like Gitlab written in Ruby vs Gogs (with
> Drone CI) both written in golang.
>
> Gitlab requires about 2GB Memory (minimum) to run in production with as
> little as 10 users. If you have less than that Gitlab will feel really,
> really slow and even sometimes run into "out of memory" errors.
>
> Now Gogs on the other side uses about 20MB of memory. Sure, Gitlab is at
> this point more mature than Gogs but is it sustainable? Consider having to
> host these two on DigitalOcean for example. You will need at least the 2GB
> Droplet for Gitlab whereas the 512MB Droplet will be more than sufficient
> for Gogs. You can even turn it up a notch. If you want to host 20 instances
> of Gitlab or Gogs. For Gitlab you will need 20 of the 2GB Droplets, adding
> up to $400/month. But for gogs the SINGLE 512MB will still be sufficient at
> $5/month.
>
> Now that is enough on the Memory side. Golang can be built as a "static
> binary" which means the SINGLE binary file contains everything about the
> the application. Consider this article:
> https://blog.codeship.com/building-minimal-docker-containers-for-go-applications/,
> where the static linked binary is a mere 5.6MB in size. If you take .NET
> you will probably need IIS and the .NET Framework on top of your
> application.
>
> Golang also actually include the http server in this 5.6MB of static
> binary. So no need for another layer like IIS.
>
> Just a handy tip. There are "awesome lists" of about any framework and
> language out there:
>
>- Curated list of them all: https://github.com/sindresorhus/awesome
>- Golang: https://github.com/avelino/awesome-go and
>https://github.com/golang/go/wiki/Projects
>- .NET Core: https://github.com/thangchung/awesome-dotnet-core
>
>
>
>
> On Wednesday, 18 May 2016 16:06:30 UTC+2, Sotirios Mantziaris wrote:
>
> Dear Tim,
>
> We are a .Net house and we are running "windows services" for months
> without having any problem. Sql Server, which is a very robust RDBMS, is a
> windows service and runs rock solid for years. So the issues you mentioned
> are mainly your own code issues.
>
> Windows has a feature called Task Scheduler where you can schedule
> anything to run on a schedule if that is what you want.
>
> The claim that .Net is not heavily concurrent is not true either. You can
> use TPL (Task Parallel Library) and run a really solid and performant
> concurrent programming model with ease.
> This will scale very nicely with the cores of your machine. Especially
> when using Parallel.For which does some optimizations.
>
> Long story short. Please try to be correct on your claims since you are
> sounding like you don't know windows and .net that much. no harm intended.
>
> Kind regards
>
> On Wednesday, May 18, 2016 at 5:09:13 AM UTC+3, Tim Hawkins wrote:
>
> He mentions that they have a bunch of Web scrappers,  this kind of task is
> heavily concurrent, something that .net is not know for, but golang is. We
> are a php house, but we are switching to go for this one reason, our new
> internal stack wil be based on php frontend,  golang based microservices
> layers, and mysql, elasticsearch and mongo based data stor

Re: [go-nuts] Re: .net core vs go

2016-10-08 Thread Sotirios Mantziaris
This is actually my go setup along with delve for debugging.

On Sat, Oct 8, 2016, 11:36 Francois Hill  wrote:

> Hi, yes I agree with the fact that Visual Studio is one of the best IDE's
> out there. But in general tooling, golang has a great set too. I suggest
> you check out VS Code with golang extension, pretty neat! And on top of
> that VS Code is cross-platform too.
>
>
>
> On Sat, 8 Oct 2016, 09:15 Sotirios Mantziaris, 
> wrote:
>
> Hi,
>
> i too use go and i see all the benefits that you are mentioning. I was
> only pointing out what was wrong in the post about windows...
>
> BTW You don't need IIS to run .Net Core. There is a new web server named
> Kestrel (check this video https://vimeo.com/172009499) which performs
> very well.
> So creating docker containers is straightforward too. You just need more
> files to deploy instead of one and if you automated this it should not
> matter!
>
> BTW There is a project research named .Net Native which will eventually
> create on static linked binary!!!
>
> I do not have any idea about memory consumption on .net core., this would
> be nice to check out! Comparing ruby with go is a little off, since ruby is
> not known to be performant and cheap on memory.
>
> Creating apps with both is very nice. go gives you what you have
> mentioned. .net core almost the same with better tooling (Visual Studio
> rocks)
>
>
> On Saturday, October 8, 2016 at 9:25:27 AM UTC+3, francoi...@gmail.com
> wrote:
>
> Hi Sotirios
>
> I have always been someone trying to balance out the "developer
> productivity" vs "runtime efficiency". By only using a coding
> language/framework because you can code much quicker in it is almost 99% of
> the time going to bite you in the *** later. Sure if you just want to
> "prototype" something it doesn't matter. But how often does the prototype
> not become the starting point and turn into the "legacy" black-box nobody
> want to touch.
>
> Consider for instance something like Gitlab written in Ruby vs Gogs (with
> Drone CI) both written in golang.
>
> Gitlab requires about 2GB Memory (minimum) to run in production with as
> little as 10 users. If you have less than that Gitlab will feel really,
> really slow and even sometimes run into "out of memory" errors.
>
> Now Gogs on the other side uses about 20MB of memory. Sure, Gitlab is at
> this point more mature than Gogs but is it sustainable? Consider having to
> host these two on DigitalOcean for example. You will need at least the 2GB
> Droplet for Gitlab whereas the 512MB Droplet will be more than sufficient
> for Gogs. You can even turn it up a notch. If you want to host 20 instances
> of Gitlab or Gogs. For Gitlab you will need 20 of the 2GB Droplets, adding
> up to $400/month. But for gogs the SINGLE 512MB will still be sufficient at
> $5/month.
>
> Now that is enough on the Memory side. Golang can be built as a "static
> binary" which means the SINGLE binary file contains everything about the
> the application. Consider this article:
> https://blog.codeship.com/building-minimal-docker-containers-for-go-applications/,
> where the static linked binary is a mere 5.6MB in size. If you take .NET
> you will probably need IIS and the .NET Framework on top of your
> application.
>
> Golang also actually include the http server in this 5.6MB of static
> binary. So no need for another layer like IIS.
>
> Just a handy tip. There are "awesome lists" of about any framework and
> language out there:
>
>- Curated list of them all: https://github.com/sindresorhus/awesome
>- Golang: https://github.com/avelino/awesome-go and
>https://github.com/golang/go/wiki/Projects
>- .NET Core: https://github.com/thangchung/awesome-dotnet-core
>
>
>
>
> On Wednesday, 18 May 2016 16:06:30 UTC+2, Sotirios Mantziaris wrote:
>
> Dear Tim,
>
> We are a .Net house and we are running "windows services" for months
> without having any problem. Sql Server, which is a very robust RDBMS, is a
> windows service and runs rock solid for years. So the issues you mentioned
> are mainly your own code issues.
>
> Windows has a feature called Task Scheduler where you can schedule
> anything to run on a schedule if that is what you want.
>
> The claim that .Net is not heavily concurrent is not true either. You can
> use TPL (Task Parallel Library) and run a really solid and performant
> concurrent programming model with ease.
> This will scale very nicely with the cores of your machine. Especially
> when using Parallel.For which does some optimizations.
>
> Long story short. Please try to be correct on your claims since you are
> sounding like you don't know windows and .net that much. no harm intended.
>
> Kind regards
>
> On Wednesday, May 18, 2016 at 5:09:13 AM UTC+3, Tim Hawkins wrote:
>
> He mentions that they have a bunch of Web scrappers,  this kind of task is
> heavily concurrent, something that .net is not know for, but golang is. We
> are a php house, but we are switching to go for this one reason, our new
> inter

[go-nuts] what's the difference between Golang and Java about interface?

2016-10-08 Thread Fei Ding


Recently I've been asked a question which is, what's the difference between 
Golang and Java about *interface*?


I know there are some 'syntax-sugar level' differences, what I am 
interested is anything beneath the ground, like how does Golang and Java 
implement interface? What's the biggest difference? Which one is more 
efficient? Why?


Could anyone post blog links or source code about this topic? The only code 
I can find is in src/runtime/iface.go, but I cannot understand it or get 
anything useful by myself yet. Source code is better.


Thanks.

-- 
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: tidy way to write a repeat-until in golang

2016-10-08 Thread xiiophen
If you can stomach GOTO the code :

i := a

loop1: //stuff

//..fmt.Println(i, a, b)

//stuff

if i != b {

i = i + b - a

goto loop1

}

 
should compile to something fairly sane without the extra variables and 
'ifs'

..but it lacks local scope, and the indentation isn't helpful. It's not 
good to read when there are multiple loops like a 3d array case.

-- 
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] No DNS TTL information in net.LookupSRV()

2016-10-08 Thread sandro . santilli


Il giorno mercoledì 13 aprile 2016 22:45:48 UTC+2, Ian Lance Taylor ha 
scritto:
>
> On Wed, Apr 13, 2016 at 12:31 PM, fyodor  > wrote: 
> > Is there a way to obtain TTL information from through the DNS lookup 
> methods 
> > in the net package? 
>
> Not at present. 
>
> > I'm implementing a component that uses SRV records from a DNS server and 
> i 
> > noticed TTL number aren't returned with the net.LookupSRV function. 
> > 
> > 
> https://github.com/golang/go/blob/0104a31b8fbcbe52728a08867b26415d282c35d2/src/net/dnsclient.go#L187
>  
> > 
> > The TTL information is in the DNS header returned in the response but i 
> > can't see a way just getting the header. 
> > 
> > https://github.com/golang/go/blob/master/src/net/dnsmsg.go#L126 
> > 
> > Would it be worth my while to implement something for this and submit 
> this 
> > for inclusion in a forthcoming release of Go? 
>
> It seems reasonable to me.  You should your API proposal to golang-dev 
> before you much time into it. 
>

Did anything move on this front ? I've the same problem, in look for a TTL 
value for my lookups...

--strk;

-- 
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] Turning off nagle's algorithm for http.Client

2016-10-08 Thread hay
Hi,

I'm using http.Client to make restful calls, turning off nagle's algorithm 
will help as messages are very short and response time needs to be fast. Is 
there a way to check or/and set to turn off 'NoDelay'/Nagle's algorithm for 
http.Client ( https://golang.org/pkg/net/http/#Client ) ?

Regards and thanks in advance,


-- 
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] Working example of server to server Google API for calendar

2016-10-08 Thread lacroix . jean . luc
I am just starting with Go and I want to rewrite a PHP app that read/write 
events to and from my user's calendars. That app uses an API service 
account key ("two-legged OAuth" - server to server authentication) to 
access the calendar that my users have granted r/w access to my Service 
Account email address.

I have installed the google.golang.org 
 API package where an 
example "calendar.go" is to be found. Could not get it running. It produces 
an error: "undefined: registerDemo". This thread 
 wasn't very 
helpful to get me going.

I also read this Google API guide 
. 
Example code are given in Java, PHP and Python but not for Go!

I am kind of stuck.

Can someone point me in the right direction? Any good working example or 
step-by-step howto for a Go newbie?

-- 
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 difference between Golang and Java about interface?

2016-10-08 Thread Pietro Gagliardi
The most obvious difference is that Go doesn't have the implements keyword. All 
you have to do to implement an interface is implement the interface's methods, 
and the Go compiler will take care of the rest.

This rule leads to the empty interface, interface{}. This interface requires no 
methods to be satisfied, and as such is satisfied by all types, including the 
builtin types such as int64.

Go interfaces can be satisfied by any kind of type, not just struct types.

type MySpecialInt int
func (m MySpecialInt) String() string {
return fmt.Sprintf("Hello! I'm %d!", int(m))
}
// MySpecialInt implements fmt.Stringer, so printing it with fmt 
functions will use the String() method

In Go, you do not have to predeclare your interface types;

func x(y interface{ T() }) { y.T() }

is valid.

Go does not have surrounding types, so the rules about having an interface in a 
Java class mean nothing to Go. This is only really relevant in one place: In 
Java, if you have an interface method marked private, only the surrounding 
class can implement that specific method, not the entire package. In Go, the 
entire package is able to implement an unexported method in an interface, but 
other packages cannot:

package a
type Y interface { q() }

package b
type X int
func (X) q() { ... } // X does NOT implement a.Y!

However, types in other packages CAN satisfy unexported interfaces:

package a
type y interface { Q() }

package b
type X int
func (X) Q() { ... } // X DOES implement a.y

Go does not have generic types, protected inheritance, static members, abstract 
types, final members, or strictfp, so those annotations in Java interfaces are 
unavailable. (In Go's case, there is *only* strictfp; the specification implies 
in lots of places that IEEE 754 is required, though looking at it again I'm not 
sure if a superset of IEEE 754 is acceptable or not...)

Go interfaces may only specify methods; Java interfaces may also specify fields 
and nested types. (This makes sense; Go interfaces can apply to any type, and 
only structs have "fields", and Go does not have nested types.)

Java interfaces can provide a default implementation for methods that an 
implementing class may choose not to override. Go interfaces cannot.

Go does not have the same types of annotations that Java has, so @interface is 
meaningless. For details on Go's closest approximation, see struct tags.

Go does not have functional interfaces or interface literals.

> On Oct 8, 2016, at 9:14 AM, Fei Ding  wrote:
> 
> Recently I've been asked a question which is, what's the difference between 
> Golang and Java about interface?
> 
> 
> 
> I know there are some 'syntax-sugar level' differences, what I am interested 
> is anything beneath the ground, like how does Golang and Java implement 
> interface? What's the biggest difference? Which one is more efficient? Why?
> 
> 
> 
> Could anyone post blog links or source code about this topic? The only code I 
> can find is in src/runtime/iface.go, but I cannot understand it or get 
> anything useful by myself yet. Source code is better.
> 
> 
> 
> Thanks.
> 
> 
> -- 
> 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] what's the difference between Golang and Java about interface?

2016-10-08 Thread Jan Mercl
On Sat, Oct 8, 2016, 16:39 Pietro Gagliardi  wrote:

>
>
> Go does not have functional interfaces or interface literals.
>

I don't know what is meant by 'functional interfaces' but Go definitely
supports interface literals.

-- 

-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] what's the difference between Golang and Java about interface?

2016-10-08 Thread Pietro Gagliardi
In Java, if an interface contains exactly one method, and that method is not 
already part of java.lang.Object, the syntax

Interface i = (arguments) -> {
code
};

will make an object i of that interface type with the given closure as the 
method body. This interface is called a functional interface.

Pre-Java 8, the same thing could be done with

Interface i = new Interface() {
public void method() {
code
}
};

These interface literals are different from Go's interface literals.

> On Oct 8, 2016, at 11:24 AM, Jan Mercl <0xj...@gmail.com> wrote:
> 
> 
> 
> On Sat, Oct 8, 2016, 16:39 Pietro Gagliardi  > wrote:
> 
> 
> Go does not have functional interfaces or interface literals.
> 
> I don't know what is meant by 'functional interfaces' but Go definitely 
> supports interface literals.
> 
> -- 
> -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] what's the difference between Golang and Java about interface?

2016-10-08 Thread Henrik Johansson
But that is just syntactic sugar around the fact that Java does not have
first class functions. At least not in the sense Go does.

On Sat, Oct 8, 2016, 17:31 Pietro Gagliardi  wrote:

> In Java, if an interface contains exactly one method, and that method is
> not already part of java.lang.Object, the syntax
>
> Interface i = (arguments) -> {
> code
> };
>
> will make an object i of that interface type with the given closure as the
> method body. This interface is called a functional interface.
>
> Pre-Java 8, the same thing could be done with
>
> Interface i = new Interface() {
> public void method() {
> code
> }
> };
>
> These interface literals are different from Go's interface literals.
>
> On Oct 8, 2016, at 11:24 AM, Jan Mercl <0xj...@gmail.com> wrote:
>
>
>
> On Sat, Oct 8, 2016, 16:39 Pietro Gagliardi  wrote:
>
>
>
> Go does not have functional interfaces or interface literals.
>
>
> I don't know what is meant by 'functional interfaces' but Go definitely
> supports interface literals.
>
> --
>
> -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.
>

-- 
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] Suggestions for parsing Forwarded HTTP Header (RFC 7239)

2016-10-08 Thread Tim Heckman
Hey Gophers!

I'm working on a small project where I'm looking to support the "Forwarded" 
header as defined in RFC-7239[1]. For those unfamiliar, it's a 
standardization and unification of the "X-Forwarded-For" and 
"X-Forwarded-Proto" headers, among others. The simplest version of the 
header looks like the following:

Forwarded: for=192.0.2.1; by=192.0.2.2; proto=http

My initial (naïve) thought was that I could use the 
mime.ParseMediaType()[2] function to parse the value of the header. This 
results in an error because that function is only designed to parse things 
like the "Content-Disposition" header (i.e., things that have a media-type 
before the key=value parameters).

Reading RFC-7239 further, it becomes quite apparent that more complex 
header values are possible. You can not only have multiple Forwarded 
headers, but you can also have multiples of the key=value parameters within 
a single header-value. This means even the parameter parsing code of the 
mime.ParseMediaType() function isn't compatible if the request has the 
following (notice the comma in line 2):

Forwarded: for=192.0.2.42; proto=http
Forwarded: for=192.0.2.1, for=64.72.88.33

At the time of writing, RFC-7239 is in the Proposed Standard status 
(meaning it's ripe for implementation support). I've been doing some 
digging, and it doesn't seem like the stdlib of Go is capable of parsing 
this header in a meaningful way. Likewise, it doesn't look like anyone has 
tackled parsing this header as a third-party package.

I wouldn't want to duplicate effort, so does anyone know if someone has 
built a package for parsing this header?
Do you think it's a good idea to open an issue on the Go project to inquire 
about implementing a parser, in the "mime" package, that's capable of 
extracting the parameters from all "Forwarded" header values of a request? 
Is this a better fit for a third-party package?

Cheers!
-Tim

[1] https://tools.ietf.org/html/rfc7239 
[2] https://golang.org/pkg/mime/#ParseMediaType

-- 
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: tidy way to write a repeat-until in golang

2016-10-08 Thread Egon


On Saturday, 8 October 2016 16:34:33 UTC+3, xiio...@gmail.com wrote:
>
> If you can stomach GOTO the code :
>
> i := a
>
> loop1: //stuff
>
> //..fmt.Println(i, a, b)
>
> //stuff
>
> if i != b {
>
> i = i + b - a
>
> goto loop1
>
> }
>
>  
> should compile to something fairly sane without the extra variables and 
> 'ifs'
>
> ..but it lacks local scope, and the indentation isn't helpful. It's not 
> good to read when there are multiple loops like a 3d array case.
>

In this code you could use empty blocks, e.g.:

{
i := 0
loop:
fmt.Println(i)
if i < 10 {
i++
goto loop
}
}

or:

  i := 0
{
loop:
fmt.Println(i)
if i < 10 {
i++
goto loop
}
}

or:

i := 0
loop:
{
fmt.Println(i)
if i < 10 {
i++
goto loop
}
}

-- 
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: MSACCESS with Go ?

2016-10-08 Thread wilk
On 07-10-2016, Konstantin Khomoutov wrote:
> On Thu, 6 Oct 2016 20:24:47 + (UTC)
> wilk  wrote:
>
>> I know... but i must access to MSACCESS database. I would like to use
>> Go instead of Python.
>> I found alexbrainman/odbc and it works. I found some litle issues
>> that I submited to the project but I think I can workaround.
>> 
>> Before I continue to dig, are there others Gophers using MSACCESS ?
>> In production ?
>
> I'm not doig this, but I'm pretty sure using its native drivers through
> ODBC is pretty much the most sensible way to go about dealing with your
> task.  And that alexbrainman/odbc driver is of good quality and is well
> maintained.

Fine, I'm confident of the quality of this driver, I'll continue to try.

>
> Well, in theory, you could take another route and write some low-level
> glue code in C++ to use the OLE DB "Jet database" drivers, and then
> make use of that code in your Go project (on Windows, you could avoid
> using `cgo` by building a DLL with your glue code and accessing it from
> Go using the same way alexbrainman/odbc deals with ODBC DLLs).
> I'm afraid this is too much work for too little gain though.
> So I'd go with ODBC untill you encounter some major unfixable roadblock
> going that way.
>
> It could also be possible to use the MS Jet DLL directly but I'm again
> afraid that would be even more work that accessing it through OLE DB
> layer.

I'm happy that there are other possibilities.
But I'm affraid to be alone using MSACCESS with Go. Even if I understand 
that nobody want to invest in this.

-- 
William

-- 
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] Turning off nagle's algorithm for http.Client

2016-10-08 Thread Janne Snabb
In the http.Client that you use, specify your own Transport where you
specify your own DialContext function which Dials first and then calls
SetNoDelay on the connection before returning.

Janne Snabb
sn...@epipe.com

On 2016-10-08 11:25, hay wrote:
> Hi,
> 
> I'm using http.Client to make restful calls, turning off nagle's
> algorithm will help as messages are very short and response time needs
> to be fast. Is there a way to check or/and set to turn off
> 'NoDelay'/Nagle's algorithm for http.Client (
> https://golang.org/pkg/net/http/#Client ) ?
> 
> Regards and thanks in advance,
> 
> 
> -- 
> 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] what's the difference between Golang and Java about interface?

2016-10-08 Thread Pietro Gagliardi
Of course. And in Go you would write code in a way that would avoid the need 
for such constructs in the first place.

Aside: is there a way to get El Capitan Mail.app to play nice with Google 
Groups?

> On Oct 8, 2016, at 12:04 PM, Henrik Johansson  wrote:
> 
> But that is just syntactic sugar around the fact that Java does not have 
> first class functions. At least not in the sense Go does.
> 
> 
> On Sat, Oct 8, 2016, 17:31 Pietro Gagliardi  > wrote:
> In Java, if an interface contains exactly one method, and that method is not 
> already part of java.lang.Object, the syntax
> 
>   Interface i = (arguments) -> {
>   code
>   };
> 
> will make an object i of that interface type with the given closure as the 
> method body. This interface is called a functional interface.
> 
> Pre-Java 8, the same thing could be done with
> 
>   Interface i = new Interface() {
>   public void method() {
>   code
>   }
>   };
> 
> These interface literals are different from Go's interface literals.
> 
>> On Oct 8, 2016, at 11:24 AM, Jan Mercl <0xj...@gmail.com 
>> > wrote:
>> 
>> 
>> 
>> On Sat, Oct 8, 2016, 16:39 Pietro Gagliardi > > wrote:
>> 
>> 
>> Go does not have functional interfaces or interface literals.
>> 
>> I don't know what is meant by 'functional interfaces' but Go definitely 
>> supports interface literals.
>> 
>> -- 
>> -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 
> .
> 
> -- 
> 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.


[go-nuts] Re: tidy way to write a repeat-until in golang

2016-10-08 Thread xiiophen


On Saturday, 8 October 2016 20:19:37 UTC+1, Egon wrote:
>
>
>
> In this code you could use empty blocks, e.g.:
>
> {
> i := 0
> loop:
> fmt.Println(i)
> if i < 10 {
> i++
> goto loop
> }
> }
>
> or:
>
>   i := 0
> {
> loop:
> fmt.Println(i)
> if i < 10 {
> i++
> goto loop
> }
> }
>
> or:
>
> i := 0
> loop:
> {
> fmt.Println(i)
> if i < 10 {
> i++
> goto loop
> }
> }
>

Yeah I somehow forgot I could arbitrarily use brackets for scope (and fmt 
indentation) - I guess the "i" should be local to the loop so the first way 
seems to make the most sense.

In the short loop case the 'goto' form is much faster (2x) than the one 
with the boolean, and about the same as the example with the break 
conditions in the second if - which reads ok.

I suppose a go-ish form of repeat-until or do-while would look something 
like this

repeat i := a.X {

repeat j := a.Y {

repeat k := a.Z {


//fmt.Println(" xyz ", i, j, k)


} until k == b.Z; k = k + b.Z - a.Z

} until j == b.Y; j = j + b.Y - a.Y

} until i == b.X; i = i + b.X - a.X


 

-- 
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: tidy way to write a repeat-until in golang

2016-10-08 Thread Gary Scarr


I prefer to show the intent of the bool with something like

for done :=false;!done;{


//stuff


done = xxx // done = expr in until(expr)


}






On Friday, October 7, 2016 at 7:25:02 PM UTC-4, xiio...@gmail.com wrote:
>
> Any suggestions on a way to write a repeat until loop equivalent in golang 
> that looks tidy
>
> currently I do :
>
> ib := true
> for i := a.X; i != b.X || ib; i = i + b.X - a.X {
> ib = false
> //stuff
> }
>
>  
> for loops that need to be executed once under all conditions..
>
> maybe there's neater or better way ?
>  
>
>
>

-- 
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] context.Context in a TLS proxy

2016-10-08 Thread 'Anmol Sethi' via golang-nuts
My TLS proxy used to create two goroutines of `io.Copy` to copy between the
incoming and outgoing connection.

As soon as `io.Copy` returned, with or without an error, I closed both
connections. This had the effect that on the other goroutine, the
Read/Write returned with errors about the "use of a closed network
connection".

In order to prevent the errors, I used context.Context like this:
https://github.com/nhooyr/tlswrapd/blob/master/proxy.go#L88-L143

Several things I am unsure about now. First, I feel like I am misusing
context.Context. Second, should I even bother synchronizing everything
myself? As in, should I just have a channel with a single buffer where the
first error is sent and then only print that and assume the other error is
a result from closing the connections?

-- 
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: context.Context in a TLS proxy

2016-10-08 Thread 'Anmol Sethi' via golang-nuts
Sorry, my mistake. Use
https://github.com/nhooyr/tlswrapd/blob/15b03321169039a4042434086d841a660a7afd88/proxy.go#L88-L143
as
the link incase I change things and the line numbers become incorrect.

On Sat, Oct 8, 2016 at 11:43 PM Anmol Sethi  wrote:

> My TLS proxy used to create two goroutines of `io.Copy` to copy between
> the incoming and outgoing connection.
>
> As soon as `io.Copy` returned, with or without an error, I closed both
> connections. This had the effect that on the other goroutine, the
> Read/Write returned with errors about the "use of a closed network
> connection".
>
> In order to prevent the errors, I used context.Context like this:
> https://github.com/nhooyr/tlswrapd/blob/master/proxy.go#L88-L143
>
> Several things I am unsure about now. First, I feel like I am misusing
> context.Context. Second, should I even bother synchronizing everything
> myself? As in, should I just have a channel with a single buffer where the
> first error is sent and then only print that and assume the other error is
> a result from closing the connections?
>

-- 
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 create a go app win, linux of etc ?????

2016-10-08 Thread Gary Scarr


On Monday, October 3, 2016 at 2:34:31 PM UTC-4, hadies...@gmail.com wrote:
>
> mean is : i want create application for window or others platforms
>
> If you only want a gui for Windows, the simplest go-gettable package I've 
>> found with useful examples  is https://github.com/lxn/walk
>>
>>
>>
>>

-- 
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: context.Context in a TLS proxy

2016-10-08 Thread 'Anmol Sethi' via golang-nuts
Ok, so I think I've got it really nice now:
https://github.com/nhooyr/tlswrapd/blob/master/proxy.go#L87-L110

Much simpler by only using the first error.

On Sat, Oct 8, 2016 at 11:45 PM Anmol Sethi  wrote:

> Sorry, my mistake. Use
> https://github.com/nhooyr/tlswrapd/blob/15b03321169039a4042434086d841a660a7afd88/proxy.go#L88-L143
>  as
> the link incase I change things and the line numbers become incorrect.
>
> On Sat, Oct 8, 2016 at 11:43 PM Anmol Sethi  wrote:
>
> My TLS proxy used to create two goroutines of `io.Copy` to copy between
> the incoming and outgoing connection.
>
> As soon as `io.Copy` returned, with or without an error, I closed both
> connections. This had the effect that on the other goroutine, the
> Read/Write returned with errors about the "use of a closed network
> connection".
>
> In order to prevent the errors, I used context.Context like this:
> https://github.com/nhooyr/tlswrapd/blob/master/proxy.go#L88-L143
>
> Several things I am unsure about now. First, I feel like I am misusing
> context.Context. Second, should I even bother synchronizing everything
> myself? As in, should I just have a channel with a single buffer where the
> first error is sent and then only print that and assume the other error is
> a result from closing the connections?
>
>

-- 
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: context.Context in a TLS proxy

2016-10-08 Thread 'Anmol Sethi' via golang-nuts
Arg, use
https://github.com/nhooyr/tlswrapd/blob/965c34913d5c8635b07ec8fb4918174298fa4855/proxy.go#L87-L110

On Sun, Oct 9, 2016 at 12:45 AM Anmol Sethi  wrote:

> Ok, so I think I've got it really nice now:
> https://github.com/nhooyr/tlswrapd/blob/master/proxy.go#L87-L110
>
> Much simpler by only using the first error.
>
> On Sat, Oct 8, 2016 at 11:45 PM Anmol Sethi  wrote:
>
> Sorry, my mistake. Use
> https://github.com/nhooyr/tlswrapd/blob/15b03321169039a4042434086d841a660a7afd88/proxy.go#L88-L143
>  as
> the link incase I change things and the line numbers become incorrect.
>
> On Sat, Oct 8, 2016 at 11:43 PM Anmol Sethi  wrote:
>
> My TLS proxy used to create two goroutines of `io.Copy` to copy between
> the incoming and outgoing connection.
>
> As soon as `io.Copy` returned, with or without an error, I closed both
> connections. This had the effect that on the other goroutine, the
> Read/Write returned with errors about the "use of a closed network
> connection".
>
> In order to prevent the errors, I used context.Context like this:
> https://github.com/nhooyr/tlswrapd/blob/master/proxy.go#L88-L143
>
> Several things I am unsure about now. First, I feel like I am misusing
> context.Context. Second, should I even bother synchronizing everything
> myself? As in, should I just have a channel with a single buffer where the
> first error is sent and then only print that and assume the other error is
> a result from closing the connections?
>
>

-- 
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: .net core vs go

2016-10-08 Thread Sotirios Mantziaris
Hi Jan. The correct analogy here are not threads but Tasks from the 
excellent Task Parallel Library in order to compare Apples with Apples. 

i have a little stupid source code (https://github.com/mantzas/headon) that 
run in parallel n tasks and the equivalent in go.

dotnet run 100
Project dotnet (.NETCoreApp,Version=v1.0) was previously compiled. Skipping 
compilation.
Task to execute: 100
100 in 00:00:00.8903075
 
go.exe -tasks 100
Task to execute: 100
100 in 3.9731993s

when running higher number of tasks like 1000 i get:

λ dotnet run 1000
Project dotnet (.NETCoreApp,Version=v1.0) was previously compiled. Skipping 
compilation.
Task to execute: 1000
1000 in 00:00:07.9395814

the same in go had the following result:
eating all my memory and crashed

BTW the dotnet memory consumption is around 700 MB. 
When using dotnet's Parallel.For we have even better results

λ dotnet run 1000
Project dotnet (.NETCoreApp,Version=v1.0) was previously compiled. Skipping 
compilation.
Task to execute: 1000
1000 in 00:00:00.8419129

and the memory consumption is around 7MB!!!

i have tested the same in Linux so i could say the following based on the 
above:

dotnet has a better implemented concurrency library allowing only some 
tasks to run concurrently (POOL) and it is by a lot faster than goroutines.

in go you can shoot yourself in the foot easily.

Please review my code for any mistakes i made and let me know.




On Saturday, October 8, 2016 at 10:33:24 AM UTC+3, Jan Mercl wrote:
>
> On Wed, May 18, 2016 at 4:06 PM Sotirios Mantziaris  > wrote:
>
> > The claim that .Net is not heavily concurrent is not true either. 
>
> A Go program executing 100k goroutines needs 200MB or 400MB RAM for stack, 
> depending on version, so it can run just fine. A .net program trying to 
> execute 100k threads will OOM way before reaching a even a small fraction 
> of the goal.
>
> -- 
>
> -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.