Re: [go-nuts] [generics] generic types join through pipes

2020-11-20 Thread Ian Lance Taylor
On Fri, Nov 20, 2020 at 2:58 PM Reindert Vetter  wrote:
>
> First of all, thank you for everything you do with Go!
>
> I've had an idea for generic for Go for some time. If it makes no sense, 
> please ignore my email.
>
> The idea is to join the different types through a pipe. This means you do not 
> have to introduce a 'type' in the interface. It is also much easier to 
> convert ordinary types to a generic type.
>
> Some examples:
>
> type typeFloat float64
> type typeInt int
> type stringAble typeFloat|typeInt
>
> func ConvertToString(input stringAble) string {
>//
> }
>
>
> type stringAble float64|int
>
> func ConvertToString[type T stringAble](input []T) string {
>//
> }
>
>
> With interfaces:
>
> type stringAble typeFloat|typeInt|error|stringer
>
> func ConvertToString(input stringAble) string {
> //
> }
>
>
> They may not be generics, but you could also allow the following:
>
>
> func ConvertToString(input float64|int) string {
>//
> }
>
>
> type typeFloat float64
> type typeInt int
>
> func ConvertToString(input typeFloat|typeInt) string {
>//
> }


This has some similarities to sum types: https://golang.org/issue/19412.

I'm not sure how to write a genreric Min function with this approach.

Thanks for the note.

Ian

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/CAOyqgcUt8mTmXYO3YYPhSsDuNOjDA%2BzKxfrXKxhFt5vaeQV3BA%40mail.gmail.com.


[go-nuts] Estimating blockers for supporting gollvm on RISC-V (qemu). Fedora 33

2020-11-20 Thread Ivan Serdyuk
Hello.

It is just a brief survey - but I am currently dealing with a messy setup, 
for qemu.

I have upgraded, after bootstrapping( the manual 
 ) and I am 
able to boot

> Fedora (5.8.0-1.0.riscv64.fc33.riscv64) 33 (Rawhide)

kernel, under qemu.

I see a very abstract

> $ cat /proc/cpuinfo
> processor : 0
> hart : 0
> isa : rv64imafdcsu
> mmu : sv48
. 

Doesn't really help.
I will suggest trying other emulators - but would have to compile those 
myself.

I have some concerns about gmp, mpfr and mpc (since RISC-V assumes some 
extensions, to cover such demands) - I feel that it might have more sense 
to get rid of overlaying, for the end-user use cases (which gollvm project 
itself achieves).


Ivan

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/2c9788e3-5349-4f5e-bbfc-53f300cf439bn%40googlegroups.com.


Re: [go-nuts] Online service to run Go code with Go modules support

2020-11-20 Thread Alexey Melezhik

Ahh, ok ... )))

пятница, 20 ноября 2020 г. в 20:01:22 UTC-6, kortschak: 

> That's not an error.
>
>
>
> https://github.com/rsc/quote/blob/754f68430672776c84704e2d10209a6ec700cd64/quote.go#L22-L24
>
> On Fri, 2020-11-20 at 17:49 -0800, Alexey Melezhik wrote:
> > Thanks. I receive " Don't communicate by sharing memory, share memory
> > by communicating. " error (?) when run the example
> > 
>
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/89f7090e-6fed-4d71-a2d5-71cc9144bcbfn%40googlegroups.com.


Re: [go-nuts] Online service to run Go code with Go modules support

2020-11-20 Thread 'Dan Kortschak' via golang-nuts
That's not an error.


https://github.com/rsc/quote/blob/754f68430672776c84704e2d10209a6ec700cd64/quote.go#L22-L24

On Fri, 2020-11-20 at 17:49 -0800, Alexey Melezhik wrote:
> Thanks. I receive " Don't communicate by sharing memory, share memory
> by communicating. " error (?) when run the example
> 


-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/e8d28674d78984e3142bb9f31bf7f872f2588655.camel%40kortschak.io.


Re: [go-nuts] Online service to run Go code with Go modules support

2020-11-20 Thread Aston Motes
Maybe confusingly, that's the expected output:
https://github.com/rsc/quote/blob/master/quote_test.go :)

On Fri, Nov 20, 2020 at 5:49 PM Alexey Melezhik  wrote:

> Thanks. I receive " Don't communicate by sharing memory, share memory by
> communicating. " error (?) when run the example
>
> пятница, 20 ноября 2020 г. в 17:22:44 UTC-6, kortschak:
>
>> It does, but it depends on how big of a dependency set is imported due
>> to timeout. The example below does work.
>>
>> https://play.golang.org/p/WL-OhWYsx68
>>
>> On Fri, 2020-11-20 at 22:45 +, Paul Jolly wrote:
>> > Hi,
>> >
>> > > Hi go devs. I am thinking about brining up a service that would
>> > > execute Go code with support of third party modules, so that both
>> > > Go modules developers and users could play with a code and get
>> > > immediate results without having any Go environment, through a
>> > > browser.
>> > > I've noticed that there are some similar services in the scene
>> > > right now, including goplay.space and play.golang.org but they
>> > > seems do not support third party modules usage.
>> >
>> > play.golang.org does support third party modules, at least importing
>> > them: https://play.golang.org/p/2dHQwOa7_gn
>> >
>> > On a related note, last week we released https://play-with-go.dev/
>> > which is designed to provide people with an interactive introduction
>> > to the tooling required to work with the Go programming language. The
>> > authentication is required because each guide instance is connected
>> > to
>> > a remote container which effectively gives you a full blown
>> > development environment in the browser alongside the guide (there is
>> > even the option for us to serve VSCode in a similar way, allowing the
>> > user to edit files in the remote session). But as
>> > https://play-with-go.dev/go-fundamentals_go115_en/ demonstrates, not
>> > only does it provide you with a complete development environment, but
>> > guides are automatically provisioned with remote source code
>> > repositories as required. So you interactively follow the publishing
>> > of a real module, that is then resolved via the proxy.
>> >
>> > > PS Additionally there might my different OS support ( Linuxes
>> > > distros ) so that code would be executed on respected dockers with
>> > > targeted OS internally, for people doing arch dependent
>> > > applications.
>> >
>> > With play-with-go.dev we have also explored the possibility of the
>> > user choosing the platform on which the guide should run, which would
>> > also vary the commands needed to run the guide as necessary.
>> >
>> > If play-with-go.dev is of any interest I'd be happy to talk about
>> > that
>> > more (it's an open source project, supported by sponsorship)
>> >
>> >
>> > Paul
>> >
>> > --
>> > You received this message because you are subscribed to the Google
>> > Groups "golang-nuts" group.
>> > To unsubscribe from this group and stop receiving emails from it,
>> > send an email to golang-nuts...@googlegroups.com.
>> > To view this discussion on the web visit
>> >
>> https://groups.google.com/d/msgid/golang-nuts/CACoUkn6pdz228J7s0%3D8sd-tTYNjhTVUmPG%2BH23YyPaA4C_Y9Dg%40mail.gmail.com
>> > .
>>
>>
>> --
> You received this message because you are subscribed to the Google Groups
> "golang-nuts" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to golang-nuts+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/golang-nuts/799f3a33-b658-4d58-bed2-d7b37aca194fn%40googlegroups.com
> 
> .
>

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/CANfvvbVLN6jHbEfWwF72bOWTeS-SHiX_%3DbnQ78Ps%3DYa3NDfgHQ%40mail.gmail.com.


Re: [go-nuts] Online service to run Go code with Go modules support

2020-11-20 Thread Alexey Melezhik
Hi Paul! Thanks for pointing play-with-do service. It's cool. But I'd want 
something less lowlevelish. I only want user to fill a form with code to 
run, plus some dependencies declaration if needed. Boom! Dependencies are 
installed, code is executed. You've got your report to share.
You could check out alternatively the service I've recently wrote for Raku 
- http://rakudist.raku.org/play/  Maybe I'd like to expand the same idea 
for other languages ... )))

пятница, 20 ноября 2020 г. в 16:46:38 UTC-6, Paul Jolly: 

> Hi,
>
> > Hi go devs. I am thinking about brining up a service that would execute 
> Go code with support of third party modules, so that both Go modules 
> developers and users could play with a code and get immediate results 
> without having any Go environment, through a browser.
> > I've noticed that there are some similar services in the scene right 
> now, including goplay.space and play.golang.org but they seems do not 
> support third party modules usage.
>
> play.golang.org does support third party modules, at least importing
> them: https://play.golang.org/p/2dHQwOa7_gn
>
> On a related note, last week we released https://play-with-go.dev/
> which is designed to provide people with an interactive introduction
> to the tooling required to work with the Go programming language. The
> authentication is required because each guide instance is connected to
> a remote container which effectively gives you a full blown
> development environment in the browser alongside the guide (there is
> even the option for us to serve VSCode in a similar way, allowing the
> user to edit files in the remote session). But as
> https://play-with-go.dev/go-fundamentals_go115_en/ demonstrates, not
> only does it provide you with a complete development environment, but
> guides are automatically provisioned with remote source code
> repositories as required. So you interactively follow the publishing
> of a real module, that is then resolved via the proxy.
>
> > PS Additionally there might my different OS support ( Linuxes distros ) 
> so that code would be executed on respected dockers with targeted OS 
> internally, for people doing arch dependent applications.
>
> With play-with-go.dev we have also explored the possibility of the
> user choosing the platform on which the guide should run, which would
> also vary the commands needed to run the guide as necessary.
>
> If play-with-go.dev is of any interest I'd be happy to talk about that
> more (it's an open source project, supported by sponsorship)
>
>
> Paul
>

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/d18f2e53-29b8-4834-bf33-d8b2ae87a249n%40googlegroups.com.


Re: [go-nuts] Online service to run Go code with Go modules support

2020-11-20 Thread Alexey Melezhik
Thanks. I receive " Don't communicate by sharing memory, share memory by 
communicating. " error (?) when run the example

пятница, 20 ноября 2020 г. в 17:22:44 UTC-6, kortschak: 

> It does, but it depends on how big of a dependency set is imported due
> to timeout. The example below does work.
>
> https://play.golang.org/p/WL-OhWYsx68
>
> On Fri, 2020-11-20 at 22:45 +, Paul Jolly wrote:
> > Hi,
> > 
> > > Hi go devs. I am thinking about brining up a service that would
> > > execute Go code with support of third party modules, so that both
> > > Go modules developers and users could play with a code and get
> > > immediate results without having any Go environment, through a
> > > browser.
> > > I've noticed that there are some similar services in the scene
> > > right now, including goplay.space and play.golang.org but they
> > > seems do not support third party modules usage.
> > 
> > play.golang.org does support third party modules, at least importing
> > them: https://play.golang.org/p/2dHQwOa7_gn
> > 
> > On a related note, last week we released https://play-with-go.dev/
> > which is designed to provide people with an interactive introduction
> > to the tooling required to work with the Go programming language. The
> > authentication is required because each guide instance is connected
> > to
> > a remote container which effectively gives you a full blown
> > development environment in the browser alongside the guide (there is
> > even the option for us to serve VSCode in a similar way, allowing the
> > user to edit files in the remote session). But as
> > https://play-with-go.dev/go-fundamentals_go115_en/ demonstrates, not
> > only does it provide you with a complete development environment, but
> > guides are automatically provisioned with remote source code
> > repositories as required. So you interactively follow the publishing
> > of a real module, that is then resolved via the proxy.
> > 
> > > PS Additionally there might my different OS support ( Linuxes
> > > distros ) so that code would be executed on respected dockers with
> > > targeted OS internally, for people doing arch dependent
> > > applications.
> > 
> > With play-with-go.dev we have also explored the possibility of the
> > user choosing the platform on which the guide should run, which would
> > also vary the commands needed to run the guide as necessary.
> > 
> > If play-with-go.dev is of any interest I'd be happy to talk about
> > that
> > more (it's an open source project, supported by sponsorship)
> > 
> > 
> > Paul
> > 
> > --
> > You received this message because you are subscribed to the Google
> > Groups "golang-nuts" group.
> > To unsubscribe from this group and stop receiving emails from it,
> > send an email to golang-nuts...@googlegroups.com.
> > To view this discussion on the web visit 
> > 
> https://groups.google.com/d/msgid/golang-nuts/CACoUkn6pdz228J7s0%3D8sd-tTYNjhTVUmPG%2BH23YyPaA4C_Y9Dg%40mail.gmail.com
> > .
>
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/799f3a33-b658-4d58-bed2-d7b37aca194fn%40googlegroups.com.


[go-nuts] Re: Carting int to bool and the reverse for bit hacking ?

2020-11-20 Thread silas poulson
On Friday, November 20, 2020 at 11:01:01 AM UTC b.ca...@pobox.com wrote:
>I think the moral is: don't waste your time trying to outsmart the 
compiler.

Would like to reiterate this - Godblot  is an
amazing tool for showing just how much you're compiler does for you

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/feb93ded-7379-485a-aa6d-43a34bb1d088n%40googlegroups.com.


Re: [go-nuts] Online service to run Go code with Go modules support

2020-11-20 Thread 'Dan Kortschak' via golang-nuts
It does, but it depends on how big of a dependency set is imported due
to timeout. The example below does work.

https://play.golang.org/p/WL-OhWYsx68

On Fri, 2020-11-20 at 22:45 +, Paul Jolly wrote:
> Hi,
> 
> > Hi go devs. I am thinking about brining up a service that would
> > execute Go code with support of third party modules, so that both
> > Go modules developers and users could play with a code and get
> > immediate results without having any Go environment, through a
> > browser.
> > I've noticed that there are some similar services in the scene
> > right now, including goplay.space and play.golang.org but they
> > seems do not support third party modules usage.
> 
> play.golang.org does support third party modules, at least importing
> them: https://play.golang.org/p/2dHQwOa7_gn
> 
> On a related note, last week we released https://play-with-go.dev/
> which is designed to provide people with an interactive introduction
> to the tooling required to work with the Go programming language. The
> authentication is required because each guide instance is connected
> to
> a remote container which effectively gives you a full blown
> development environment in the browser alongside the guide (there is
> even the option for us to serve VSCode in a similar way, allowing the
> user to edit files in the remote session). But as
> https://play-with-go.dev/go-fundamentals_go115_en/ demonstrates, not
> only does it provide you with a complete development environment, but
> guides are automatically provisioned with remote source code
> repositories as required. So you interactively follow the publishing
> of a real module, that is then resolved via the proxy.
> 
> > PS Additionally there might my different OS support ( Linuxes
> > distros ) so that code would be executed on respected dockers with
> > targeted OS internally, for people doing arch dependent
> > applications.
> 
> With play-with-go.dev we have also explored the possibility of the
> user choosing the platform on which the guide should run, which would
> also vary the commands needed to run the guide as necessary.
> 
> If play-with-go.dev is of any interest I'd be happy to talk about
> that
> more (it's an open source project, supported by sponsorship)
> 
> 
> Paul
> 
> --
> You received this message because you are subscribed to the Google
> Groups "golang-nuts" group.
> To unsubscribe from this group and stop receiving emails from it,
> send an email to golang-nuts+unsubscr...@googlegroups.com.
> To view this discussion on the web visit 
> https://groups.google.com/d/msgid/golang-nuts/CACoUkn6pdz228J7s0%3D8sd-tTYNjhTVUmPG%2BH23YyPaA4C_Y9Dg%40mail.gmail.com
> .


-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/daaa3c453224985db3ad63c4cbe4c172bfa3cae5.camel%40kortschak.io.


[go-nuts] [generics] generic types join through pipes

2020-11-20 Thread Reindert Vetter
Good evening,

First of all, thank you for everything you do with Go!

I've had an idea for generic for Go for some time. If it makes no sense, please 
ignore my email.

The idea is to join the different types through a pipe. This means you do not 
have to introduce a 'type' in the interface. It is also much easier to convert 
ordinary types to a generic type.

Some examples:


type typeFloat float64
type typeInt int
type stringAble typeFloat|typeInt

func ConvertToString(input stringAble) string {
   //
}


type stringAble float64|int

func ConvertToString[type T stringAble](input []T) string {
   //
}

With interfaces:

type stringAble typeFloat|typeInt|error|stringer

func ConvertToString(input stringAble) string {
//
}

They may not be generics, but you could also allow the following:


func ConvertToString(input float64|int) string {
   //
}


type typeFloat float64
type typeInt int

func ConvertToString(input typeFloat|typeInt) string {
   //
}

What do you think of this idea?

Thanks in advance!

Reindert Vetter

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/AM8PR07MB74121F954468DEAFCFE6F594CBFF0%40AM8PR07MB7412.eurprd07.prod.outlook.com.


Re: [go-nuts] Online service to run Go code with Go modules support

2020-11-20 Thread Paul Jolly
Hi,

> Hi go devs. I am thinking about brining up a service that would execute Go 
> code with support of third party modules, so that both Go modules developers 
> and users could play with a code and get immediate results without having any 
> Go environment, through a browser.
> I've noticed that there are some similar services in the scene right now, 
> including goplay.space and play.golang.org but they seems do not support 
> third party modules usage.

play.golang.org does support third party modules, at least importing
them: https://play.golang.org/p/2dHQwOa7_gn

On a related note, last week we released https://play-with-go.dev/
which is designed to provide people with an interactive introduction
to the tooling required to work with the Go programming language. The
authentication is required because each guide instance is connected to
a remote container which effectively gives you a full blown
development environment in the browser alongside the guide (there is
even the option for us to serve VSCode in a similar way, allowing the
user to edit files in the remote session). But as
https://play-with-go.dev/go-fundamentals_go115_en/ demonstrates, not
only does it provide you with a complete development environment, but
guides are automatically provisioned with remote source code
repositories as required. So you interactively follow the publishing
of a real module, that is then resolved via the proxy.

> PS Additionally there might my different OS support ( Linuxes distros ) so 
> that code would be executed on respected dockers with targeted OS internally, 
> for people doing arch dependent applications.

With play-with-go.dev we have also explored the possibility of the
user choosing the platform on which the guide should run, which would
also vary the commands needed to run the guide as necessary.

If play-with-go.dev is of any interest I'd be happy to talk about that
more (it's an open source project, supported by sponsorship)


Paul

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/CACoUkn6pdz228J7s0%3D8sd-tTYNjhTVUmPG%2BH23YyPaA4C_Y9Dg%40mail.gmail.com.


[go-nuts] Online service to run Go code with Go modules support

2020-11-20 Thread Alexey Melezhik

Hi go devs. I am thinking about brining up a service that would execute Go 
code with support of third party modules, so that both Go modules 
developers and users could play with a code and get immediate results 
without having any Go environment, through a browser.
I've noticed that there are some similar services in the scene right now, 
including goplay.space and play.golang.org but they seems do not support 
third party modules usage.

So long story short ( I am golang newbie ), would be such a service in 
demand?
Thanks for comments.

PS Additionally there might my different OS support ( Linuxes distros ) so 
that code would be executed on respected dockers with targeted OS 
internally, for people doing arch dependent applications.

You can leave your comments on reddit as well - 
https://www.reddit.com/r/golang/comments/jxytki/online_service_to_run_go_code_with_go_modules/

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/728b971f-dc29-4aa9-9826-0c5ecaf63a3cn%40googlegroups.com.


Re: [go-nuts] Alignment requirements for 64-bit atomics on 386

2020-11-20 Thread Ian Lance Taylor
On Fri, Nov 20, 2020 at 1:03 PM 'Kevin Chowski' via golang-nuts
 wrote:
>
> Thanks Ian for the very quick reply!
>
> I see you're referencing this:
>
> > On ARM, x86-32, and 32-bit MIPS, it is the caller's responsibility to 
> > arrange for 64-bit alignment of 64-bit words accessed atomically. The first 
> > word in a variable or in an allocated struct, array, or slice can be relied 
> > upon to be 64-bit aligned.
>
> Yeah it's a little unfortunate that it doesn't say i386, I ctrl-f'd for 
> "i386" on the page too and I probably would have correctly read that sentence 
> if it were in there. Unfortunately I read that sentence multiple times but I 
> guess I missed the obvious "x86" in there; my brain saw "ARM 32  32-bit MIPS" 
> and misread it as "32-bit ARM and 32-bit MIPS". My mistake for sure.

Honestly I don't think it was your mistake.  I think the docs are
confusing.  I think we should change the docs to say "i386", since
that is what we use for a GOARCH value.  I will do that if nobody
beats me to it.

Ian



> On Friday, November 20, 2020 at 1:54:28 PM UTC-7 Ian Lance Taylor wrote:
>>
>> On Fri, Nov 20, 2020 at 12:48 PM 'Kevin Chowski' via golang-nuts
>>  wrote:
>> >
>> > I am debugging an issue in which we are seeing a crash on an atomic 
>> > access; on go 1.14.7 and 1.15.2 this reproduces with the following error:
>> >
>> > > panic: runtime error: invalid memory address or nil pointer dereference
>> > > [signal SIGSEGV: segmentation violation code=0x1 addr=0x0 pc=0x8049f7c]
>> >
>> > On gotip (go version devel +3fd4917 Fri Nov 20 20:02:47 2020 + 
>> > linux/amd64) I see the following instead:
>> >
>> > > panic: unaligned 64-bit atomic operation
>> >
>> > (I'm glad the error message got better! Kudos to whomever did that.)
>> >
>> > My confusion is that I don't quite see this restriction being documented 
>> > in sync/atomic's docs: ctrl-f for "alignment" only reveals information 
>> > related to MIPS and ARM, whereas this issue is for Intel 386. Is this 
>> > working as intended (e.g. documentation bug) or is this something deeper?
>>
>> It's down at the very bottom of https://golang.org/pkg/sync/atomic, in
>> the "Bugs" section, which for some reason refers to i386 using the
>> name x86-32.
>>
>> Ian
>
> --
> You received this message because you are subscribed to the Google Groups 
> "golang-nuts" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to golang-nuts+unsubscr...@googlegroups.com.
> To view this discussion on the web visit 
> https://groups.google.com/d/msgid/golang-nuts/b92e1561-441a-4ff3-8d7c-6929801a0b9bn%40googlegroups.com.

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/CAOyqgcU3W3yGCyxrRRon3pSS%3DLiEZHvxwkf%2B-NLKk37haCf6SQ%40mail.gmail.com.


Re: [go-nuts] Alignment requirements for 64-bit atomics on 386

2020-11-20 Thread 'Kevin Chowski' via golang-nuts
Thanks Ian for the very quick reply!

I see you're referencing this:

> On ARM, x86-32, and 32-bit MIPS, it is the caller's responsibility to 
arrange for 64-bit alignment of 64-bit words accessed atomically. The first 
word in a variable or in an allocated struct, array, or slice can be relied 
upon to be 64-bit aligned.

Yeah it's a little unfortunate that it doesn't say i386, I ctrl-f'd for 
"i386" on the page too and I probably would have correctly read that 
sentence if it were in there. Unfortunately I read that sentence multiple 
times but I guess I missed the obvious "x86" in there; my brain saw "ARM 
32  32-bit MIPS" and misread it as "32-bit ARM and 32-bit MIPS". My mistake 
for sure.

Thanks again,
Kevin

On Friday, November 20, 2020 at 1:54:28 PM UTC-7 Ian Lance Taylor wrote:

> On Fri, Nov 20, 2020 at 12:48 PM 'Kevin Chowski' via golang-nuts
>  wrote:
> >
> > I am debugging an issue in which we are seeing a crash on an atomic 
> access; on go 1.14.7 and 1.15.2 this reproduces with the following error:
> >
> > > panic: runtime error: invalid memory address or nil pointer dereference
> > > [signal SIGSEGV: segmentation violation code=0x1 addr=0x0 pc=0x8049f7c]
> >
> > On gotip (go version devel +3fd4917 Fri Nov 20 20:02:47 2020 + 
> linux/amd64) I see the following instead:
> >
> > > panic: unaligned 64-bit atomic operation
> >
> > (I'm glad the error message got better! Kudos to whomever did that.)
> >
> > My confusion is that I don't quite see this restriction being documented 
> in sync/atomic's docs: ctrl-f for "alignment" only reveals information 
> related to MIPS and ARM, whereas this issue is for Intel 386. Is this 
> working as intended (e.g. documentation bug) or is this something deeper?
>
> It's down at the very bottom of https://golang.org/pkg/sync/atomic, in
> the "Bugs" section, which for some reason refers to i386 using the
> name x86-32.
>
> Ian
>

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/b92e1561-441a-4ff3-8d7c-6929801a0b9bn%40googlegroups.com.


Re: [go-nuts] How to detect if transport connection break

2020-11-20 Thread Amit Saha
On Sat, 21 Nov 2020, 2:12 am Afriyie Abraham Kwabena, <
afriyie.abra...@gmail.com> wrote:

> Hi,
>
> Yes, that is what intend to implement. Can you help with some information
> about how
> I could implement it.
> If possible some libraries or example code.
>

The standard library's http client as defined in net/http uses a transport
layer connection pool already. I believe it will take care of the scenario
you are trying to solve.

This issue https://github.com/golang/go/issues/23427 has some relevant
discussions and starting points for you to explore more. I also recommend
looking at this post https://blog.golang.org/http-tracing for further
research


Abraham
>
> On Friday, November 20, 2020 at 1:07:12 PM UTC+2 Afriyie Abraham Kwabena
> wrote:
>
>> Hi,
>>
>> Am new to programming and if you could explain further what you mean by
>> long lived process.
>>
>>
>> On Friday, November 20, 2020 at 11:41:42 AM UTC+2 amits...@gmail.com
>> wrote:
>>
>>>
>>>
>>> On Fri, 20 Nov 2020, 7:51 pm Afriyie Abraham Kwabena, <
>>> afriyie...@gmail.com> wrote:
>>>

 Hi,

 My basic understanding of HTTP protocol is that an HTTP client sent
 request, get response from the HTTP server and then the connection is
 closed.

 My question is how can an HTTP client detect if the underling transport
 connection break. For example if the HTTP server shutdown, is there a way
 to detect that at the client so that the client can start a persistent
 request.

 If possible, how can I do that in golang HTTP client?

>>>
>>> Are you thinking about implementing a connection pool for your long
>>> lived process?
>>>
>>>
>>>
 BR
 Abraham


 --
 You received this message because you are subscribed to the Google
 Groups "golang-nuts" group.
 To unsubscribe from this group and stop receiving emails from it, send
 an email to golang-nuts...@googlegroups.com.
 To view this discussion on the web visit
 https://groups.google.com/d/msgid/golang-nuts/4937b529-c1aa-4425-8b81-01214c1fc1f7n%40googlegroups.com
 
 .

>>> --
> You received this message because you are subscribed to the Google Groups
> "golang-nuts" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to golang-nuts+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/golang-nuts/d2125284-5529-4c95-82c7-3a8dac7fde78n%40googlegroups.com
> 
> .
>

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/CANODV3khLBfdEW5HnWv2P6reBNJsxnxL9mBgD%3D6-wkDUBONjdg%40mail.gmail.com.


Re: [go-nuts] Alignment requirements for 64-bit atomics on 386

2020-11-20 Thread Ian Lance Taylor
On Fri, Nov 20, 2020 at 12:48 PM 'Kevin Chowski' via golang-nuts
 wrote:
>
> I am debugging an issue in which we are seeing a crash on an atomic access; 
> on go 1.14.7 and 1.15.2 this reproduces with the following error:
>
> > panic: runtime error: invalid memory address or nil pointer dereference
> > [signal SIGSEGV: segmentation violation code=0x1 addr=0x0 pc=0x8049f7c]
>
> On gotip (go version devel +3fd4917 Fri Nov 20 20:02:47 2020 + 
> linux/amd64) I see the following instead:
>
> > panic: unaligned 64-bit atomic operation
>
> (I'm glad the error message got better! Kudos to whomever did that.)
>
> My confusion is that I don't quite see this restriction being documented in 
> sync/atomic's docs: ctrl-f for "alignment" only reveals information related 
> to MIPS and ARM, whereas this issue is for Intel 386. Is this working as 
> intended (e.g. documentation bug) or is this something deeper?

It's down at the very bottom of https://golang.org/pkg/sync/atomic, in
the "Bugs" section, which for some reason refers to i386 using the
name x86-32.

Ian

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/CAOyqgcX3F8zR2Y9ZYkkrkbZGWNj32o1j4RaYMtrc%3D%3DtW29kFLw%40mail.gmail.com.


[go-nuts] Alignment requirements for 64-bit atomics on 386

2020-11-20 Thread 'Kevin Chowski' via golang-nuts
I am debugging an issue 
 in which 
we are seeing a crash on an atomic access; on go 1.14.7 and 1.15.2 this 
reproduces with the following error: 

> panic: runtime error: invalid memory address or nil pointer dereference
> [signal SIGSEGV: segmentation violation code=0x1 addr=0x0 pc=0x8049f7c]

On gotip (go version devel +3fd4917 Fri Nov 20 20:02:47 2020 + 
linux/amd64) I see the following instead:

> panic: unaligned 64-bit atomic operation

(I'm glad the error message got better! Kudos to whomever did that.)

My confusion is that I don't quite see this restriction being documented in 
sync/atomic's 
docs : ctrl-f for "alignment" only 
reveals information related to MIPS and ARM, whereas this issue is for 
Intel 386. Is this working as intended (e.g. documentation bug) or is this 
something deeper?

-Kevin

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/6ca9f040-f101-4168-8dc8-ad6d2fcc25d0n%40googlegroups.com.


Re: [go-nuts] Ballooning Executable Sizes

2020-11-20 Thread stephen.t....@gmail.com
Yes. Thanks for your help. I've been reflecting on this and I have a couple 
of observations:

1) In some ways, the suddenly bloated executable is useful because, as in 
this case, it points to a design flaw in the program.

2) However, it was some weeks before I noticed that a problem had arisen 
because I very rarely build an executable. Using "go run . " is sufficient 
during the development cycle. This suggests that building and inspecting 
the binary should be done periodically or possibly, for "go run" to 
optionally output the resulting binary size and other statistics.

3) I've solved the problem by replacing the fixed sized array with a made 
slice. However, I can also solve the problem by making sure I use pointer 
receivers in all instances, not just those that alter the state of the 
type. Unless I've missed it I don't think there is a linter for that kind 
of thing. It would be very useful. I might have a crack at it myself.


What all of this shows is that I don't have a good mental model of how the 
compiler works. Naively, I thought it was "okay" but I've been surprised by 
a couple of the things that I've learned. For instance, why any of this 
affects the binary size. I understand why it would affect runtime memory 
usage (I would have got around to optimising that once I was confident in 
this part of the program's functionality) but why it affects the binary 
size escapes me.

So, I have a learning opportunity here: can anyone suggest good literature 
on modern compiler design? I'd like to extend my knowledge of this subject.

Thanks again to the Go team for helping.


On Thursday, November 19, 2020 at 11:37:38 PM UTC Keith Randall wrote:

> This was traced down to passing very large (multi-MB) types by value. 
> TL;DR, don't do that. See the issue for more details.
>
>
> On Thursday, November 19, 2020 at 12:59:32 PM UTC-8 ren...@ix.netcom.com 
> wrote:
>
>> Based on the OP it is occurring with 1.13,14,15 
>>
>> > On Nov 19, 2020, at 2:19 PM, Ian Lance Taylor  
>> wrote: 
>> > 
>> > On Thu, Nov 19, 2020 at 11:34 AM stephen.t@gmail.com 
>> >  wrote: 
>> >> 
>> >> I have a reasonably sized project that produces executables that have 
>> ballooned in size between two relatively simple commits. 
>> >> 
>> >> I've tested with three compiler versions and in each case the 
>> executable size is significantly larger in one case than the other. 
>> >> 
>> >> 
>> >> The changes between the two versions amount to 172 insertions and 210 
>> deletions. No module has changed version. No binary data is embedded in 
>> either version. The only additional import is to a file within the project 
>> and which is imported from many other places. 
>> >> 
>> >> I can live with the new file size if that's the way it has to be, but 
>> it's one heck of leap in size for a seemingly simple change. 
>> >> 
>> >> I've isolated the change and uploaded to a new repository for easy 
>> comparison. I would be very appreciative if someone could help me 
>> understand what is happening. 
>> >> 
>> >> https://github.com/JetSetIlly/Gopher2600-filesize-test 
>> > 
>> > 
>> > What version of Go are you using? 
>> > 
>> > 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...@googlegroups.com. 
>> > To view this discussion on the web visit 
>> https://groups.google.com/d/msgid/golang-nuts/CAOyqgcXkgaP5xDR_2vbVTQ1YHbcjhQdYH0KvM9adwacQJwhz8g%40mail.gmail.com.
>>  
>>
>>
>>

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/3df740bb-bf00-4acf-b89a-8029c4c93b71n%40googlegroups.com.


Re: [go-nuts] How to detect if transport connection break

2020-11-20 Thread Afriyie Abraham Kwabena
Hi,

Yes, that is what intend to implement. Can you help with some information 
about how
I could implement it. 
If possible some libraries or example code.

Abraham

On Friday, November 20, 2020 at 1:07:12 PM UTC+2 Afriyie Abraham Kwabena 
wrote:

> Hi,
>
> Am new to programming and if you could explain further what you mean by 
> long lived process.
>  
>
> On Friday, November 20, 2020 at 11:41:42 AM UTC+2 amits...@gmail.com 
> wrote:
>
>>
>>
>> On Fri, 20 Nov 2020, 7:51 pm Afriyie Abraham Kwabena, <
>> afriyie...@gmail.com> wrote:
>>
>>>
>>> Hi,
>>>
>>> My basic understanding of HTTP protocol is that an HTTP client sent 
>>> request, get response from the HTTP server and then the connection is 
>>> closed.
>>>
>>> My question is how can an HTTP client detect if the underling transport 
>>> connection break. For example if the HTTP server shutdown, is there a way 
>>> to detect that at the client so that the client can start a persistent 
>>> request. 
>>>
>>> If possible, how can I do that in golang HTTP client? 
>>>
>>
>> Are you thinking about implementing a connection pool for your long lived 
>> process?
>>
>>
>>
>>> BR
>>> Abraham
>>>
>>>
>>> -- 
>>> You received this message because you are subscribed to the Google 
>>> Groups "golang-nuts" group.
>>> To unsubscribe from this group and stop receiving emails from it, send 
>>> an email to golang-nuts...@googlegroups.com.
>>> To view this discussion on the web visit 
>>> https://groups.google.com/d/msgid/golang-nuts/4937b529-c1aa-4425-8b81-01214c1fc1f7n%40googlegroups.com
>>>  
>>> 
>>> .
>>>
>>

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/d2125284-5529-4c95-82c7-3a8dac7fde78n%40googlegroups.com.


Re: [go-nuts] How to detect if transport connection break

2020-11-20 Thread Afriyie Abraham Kwabena
Hi,

Am new to programming and if you could explain further what you mean by 
long lived process.
 

On Friday, November 20, 2020 at 11:41:42 AM UTC+2 amits...@gmail.com wrote:

>
>
> On Fri, 20 Nov 2020, 7:51 pm Afriyie Abraham Kwabena, <
> afriyie...@gmail.com> wrote:
>
>>
>> Hi,
>>
>> My basic understanding of HTTP protocol is that an HTTP client sent 
>> request, get response from the HTTP server and then the connection is 
>> closed.
>>
>> My question is how can an HTTP client detect if the underling transport 
>> connection break. For example if the HTTP server shutdown, is there a way 
>> to detect that at the client so that the client can start a persistent 
>> request. 
>>
>> If possible, how can I do that in golang HTTP client? 
>>
>
> Are you thinking about implementing a connection pool for your long lived 
> process?
>
>
>
>> BR
>> Abraham
>>
>>
>> -- 
>> You received this message because you are subscribed to the Google Groups 
>> "golang-nuts" group.
>> To unsubscribe from this group and stop receiving emails from it, send an 
>> email to golang-nuts...@googlegroups.com.
>> To view this discussion on the web visit 
>> https://groups.google.com/d/msgid/golang-nuts/4937b529-c1aa-4425-8b81-01214c1fc1f7n%40googlegroups.com
>>  
>> 
>> .
>>
>

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/ce2735a8-68e7-47e1-9eb4-59a825b1eb94n%40googlegroups.com.


[go-nuts] Re: Carting int to bool and the reverse for bit hacking ?

2020-11-20 Thread b.ca...@pobox.com
On Friday, 20 November 2020 at 09:26:57 UTC christoph...@gmail.com wrote:

> The use case I have to test if an integer is in a quite small constant set 
> of integers. With bool <-> int conversion, we can use binary operation like 
> this for instance which would be valid in C
>
> r := int(bool(v^v1))(bool(v^v2))(bool(v^v3))
>
>
FWIW, here's some complete C:

#include 
#include 

int Test0(int v, int v1, int v2, int v3)
{
 return v == v1 || v == v2 || v == v3;
}

int Test1(int v, int v1, int v2, int v3)
{
int r = (int)((bool)(v^v1)) & (int)((bool)(v^v2)) & (int)((bool)(v^v3));
return !r;
}

int Test2(int v, int v1, int v2, int v3)
{
int r = !!(v^v1) & !!(v^v2) & !!(v^v3);
return !r;
}

int main(void)
{
printf("%d\n", Test0(5, 1, 2, 4));
printf("%d\n", Test0(5, 1, 2, 5));
printf("%d\n", Test1(5, 1, 2, 4));
printf("%d\n", Test1(5, 1, 2, 5));
printf("%d\n", Test2(5, 1, 2, 4));
printf("%d\n", Test2(5, 1, 2, 5));
return 0;
}


Test environment:

$ gcc --version
Configured with: --prefix=/Applications/Xcode.app/Contents/Developer/usr 
--with-gxx-include-dir=/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/4.2.1
Apple clang version 11.0.0 (clang-1100.0.33.17)
Target: x86_64-apple-darwin18.7.0
Thread model: posix
InstalledDir: 
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin

Using gcc -s, I see that Test1 and Test2 do indeed compile without branches 
(using setne) whilst Test0 has branches. However with flag -O3, all three 
functions compile to identical highly-compact code without branches.

I think the moral is: don't waste your time trying to outsmart the compiler.

It's true that Go's compiler doesn't currently optimise this case, but new 
optimisations are being added over time.

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/5b4473f4-aab5-478d-91e7-3e0268671d2en%40googlegroups.com.


[go-nuts] Re: Carting int to bool and the reverse for bit hacking ?

2020-11-20 Thread b.ca...@pobox.com
On Friday, 20 November 2020 at 09:26:57 UTC christoph...@gmail.com wrote:

> A handy feature of bool <-> int conversion is that true is converted to 1 
> and any integer different of zero to true. As a consequence, when we write 
> int(bool(x)) we get 0 when x is 0, and 1 when x is not 0.
>

I don't think you've tried this with Go.
Playground 

./prog.go:9:15: cannot convert x (type int) to type bool

 It doesn't work the other way either: e.g. int(v ^ v1 != 0)

./go1.go:9:13: cannot convert v ^ v1 != 0 (type untyped bool) to type int



> This is to be compared with 
>
> r := v==v1 || v==v2 || v==v3
>
> The second form is of course more readable, but will also have a 
> conditional branch at each ||.
>


You should compare the generated machine code before saying one is better 
than the other.  If int(bool(x)) worked, it might also have a conditional 
branch; that is, it would presumably be the same as int(x != 0). In that 
case, your code becomes int(v^v1 != 0) which may or may not compile to the 
same code as int(v != v1).

To see the assembly language:  go build -gcflags -S myprog.go

Note that

> r := (v^v1)*(v^v2)*(v^v3)

risks integer overflow and may give the wrong answer. Playground 


Apart from this, I think you're trying to micro-optimise.  Do you have code 
which is measurably affected by the problem you describe, i.e. by actual 
profiling?  Modern processors have optimisations to deal with branches, 
e.g. speculative execution. Also, if you're dealing with data which is not 
in cache, then DRAM access is orders of magnitude slower than the CPU - 
i.e. the CPU cost is almost free compared to the DRAM access cost.

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/38d981a1-7579-4cdc-b166-0d6d1b43da8bn%40googlegroups.com.


Re: [go-nuts] How to detect if transport connection break

2020-11-20 Thread Amit Saha
On Fri, 20 Nov 2020, 7:51 pm Afriyie Abraham Kwabena, <
afriyie.abra...@gmail.com> wrote:

>
> Hi,
>
> My basic understanding of HTTP protocol is that an HTTP client sent
> request, get response from the HTTP server and then the connection is
> closed.
>
> My question is how can an HTTP client detect if the underling transport
> connection break. For example if the HTTP server shutdown, is there a way
> to detect that at the client so that the client can start a persistent
> request.
>
> If possible, how can I do that in golang HTTP client?
>

Are you thinking about implementing a connection pool for your long lived
process?



> BR
> Abraham
>
>
> --
> You received this message because you are subscribed to the Google Groups
> "golang-nuts" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to golang-nuts+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/golang-nuts/4937b529-c1aa-4425-8b81-01214c1fc1f7n%40googlegroups.com
> 
> .
>

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/CANODV3nbAtijdg8WybbzpDFcX26-zY-kWNQewV72Qi8VDGq9kw%40mail.gmail.com.


[go-nuts] Carting int to bool and the reverse for bit hacking ?

2020-11-20 Thread christoph...@gmail.com
Go has a strict type separation between int and bool. For a normal usage 
this is OK. I guess it also ease assembly portability because there is not 
always a machine instruction to do so. 

For bit hacking, this is an unfortunate limitation. A handy feature of bool 
<-> int conversion is that true is converted to 1 and any integer different 
of zero to true. As a consequence, when we write int(bool(x)) we get 0 when 
x is 0, and 1 when x is not 0. I checked the math/bits package and there is 
not an equivalent function.

Is there a way around this that avoids the conditional branching ? 

The use case I have to test if an integer is in a quite small constant set 
of integers. With bool <-> int conversion, we can use binary operation like 
this for instance which would be valid in C

r := int(bool(v^v1))(bool(v^v2))(bool(v^v3))

This is to be compared with 

r := v==v1 || v==v2 || v==v3

The second form is of course more readable, but will also have a 
conditional branch at each ||. If most tested integers are different from 
v1, v2 and v3, the first form seam to me more efficient due to pipelining. 
Though branching prediction can mitigate the penalty. 

The best I could do as valid Go alternative is this

r := (v^v1)*(v^v2)*(v^v3)

but the multiplication is obviously not efficient. 

Did I miss something ? 

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/a2b743d7-011d-481f-9a0f-3f00f4507328n%40googlegroups.com.


[go-nuts] How to detect if transport connection break

2020-11-20 Thread Afriyie Abraham Kwabena

Hi,

My basic understanding of HTTP protocol is that an HTTP client sent 
request, get response from the HTTP server and then the connection is 
closed.

My question is how can an HTTP client detect if the underling transport 
connection break. For example if the HTTP server shutdown, is there a way 
to detect that at the client so that the client can start a persistent 
request. 

If possible, how can I do that in golang HTTP client? 

BR
Abraham


-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/4937b529-c1aa-4425-8b81-01214c1fc1f7n%40googlegroups.com.