[go-nuts] Re: How should I avoid - literal copies lock value from

2018-08-10 Thread Kasun Vithanage
I want an slice of sets

On Tuesday, August 7, 2018 at 6:32:25 PM UTC+5:30, Dave Cheney wrote:
>
> Pass a pointer, *Set into your Diff method. 

-- 
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] filepath.WalkFunc documentation question

2018-08-10 Thread djadala
Hi,
documentation of filepath.WalkFunc state:

The path argument contains the argument to Walk as a prefix; that is, if 
> Walk is called with "dir", which is a directory containing the file "a", 
> the walk function will be called with argument "dir/a".
>

but  if the root parameter of Walk is ".", walk function is called with 
"a", not "./a".

example:
https://play.golang.org/p/PvRDSKo3KGz

Is this intentional or incorrect documentation ?

Regards,
Djadala


-- 
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] filepath.WalkFunc documentation question

2018-08-10 Thread Jan Mercl
On Fri, Aug 10, 2018 at 10:24 AM  wrote:

> Is this intentional or incorrect documentation ?

The reason is that the resulting filename is produced by Join which Cleans
the result. This should be perhaps added to the documentation.

-- 

-j

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[go-nuts] Why we chose Go to develop our cloud-based project. I hope you enjoy it!

2018-08-10 Thread Мария
Hi! Our developer Pavel Petrukhin discusses why we chose Go to develop our 
cloud-based project. I hope you enjoy it!

https://medium.com/containerum/why-we-use-go-to-develop-containerum-platform-for-kubernetes-3a33d5bdc5ec

-- 
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] no reply after writing data on TLS connection

2018-08-10 Thread Alan Lu
Hi there,

I encountered a tls problem in my code 
, I can't get reply with this 
domain. But it works on google.com:443.

What's wrong?

-- 
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 reply after writing data on TLS connection

2018-08-10 Thread Jan Mercl
On Fri, Aug 10, 2018 at 12:21 PM Alan Lu  wrote:

What's wrong?

IDK, but possibly related:
https://downforeveryoneorjustme.com/gp-cq9.tgpaccess.com

-- 

-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] no reply after writing data on TLS connection

2018-08-10 Thread Alan Lu
No, but curl and python works.


On Friday, August 10, 2018 at 6:24:34 PM UTC+8, Jan Mercl wrote:
>
> On Fri, Aug 10, 2018 at 12:21 PM Alan Lu > 
> wrote:
>
> What's wrong? 
>
> IDK, but possibly related: 
> https://downforeveryoneorjustme.com/gp-cq9.tgpaccess.com
>
> -- 
>
> -j
>

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[go-nuts] golang + wasm three times slower than javascript?

2018-08-10 Thread netbrain
So been playing around with go and wasm support on go version devel 
+479da24aac Fri Aug 10 00:47:31 2018 + linux/amd64

Curious on performance i tried implementing a Fibonacci algorithm function 
in JS and compared it to it's equivalent in GO. Calculating fib(44) takes 
11 seconds on my machine in JS and in GO it takes 36 seconds.

Any idea's to why I would get these results? I know wasm is very much an 
experimental feature of go, however I expected at least equal to or better 
performance than JS. Are there any browser optimizations which is running 
in my JS code which may not be in effect in wasm?

Test code available at https://github.com/netbrain/kata/tree/master/go/wasm

Cheers
Kim

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[go-nuts] Re: [ANN] go-set type-safe sets for Go

2018-08-10 Thread michal
Update:

We have made generating sets for your own types really easy now:

* go_generate tool was forked and you can just go-get it, see 
https://github.com/mmatczuk/go_generics
* all the generation procedure was wrapped in a bash script

In addition to that the original set implementation from 
github.com/fatih/set package was improved, most notably Copy, Union and 
Intersect are smarter in terms of memory management.

On Monday, August 6, 2018 at 7:26:23 PM UTC+2, hen...@scylladb.com wrote:
>
> Go-set is a type-safe, zero-allocation set implementation for Go.
>
> https://github.com/scylladb/go-set
>
> At Scylla we are long time users of https://github.com/fatih/set 
> 
>  
> and after it’s discontinuation we wanted to still use it. We therefore 
> created an enhanced clone with a typesafe API and high performance.
>
> We like generics a lot so we used the Google tool “go_generics” from the 
> gVisor [1]  code base to generate the concrete implementations. Most of the 
> simple language builtin types are supported.
>
>
> If you enjoy go-set come work with us, we are hiring Go Developers. Learn 
> more at https://www.scylladb.com/company/careers/
>
>
> [1] https://github.com/google/gvisor/tree/master/tools/go_generics
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[go-nuts] Re: golang + wasm three times slower than javascript?

2018-08-10 Thread jucie . andrade
As far as I know, Go is the very first garbage collected language to 
support WebAssembly. That is very important.
Remember the old motto: "first make it work, then make it right, and, 
finally, make it fast."
It is just natural that things will be improved in future releases, as 
always has been the case with Go.

Richard Musiol, from Germany, made at least 2 wonderful contributions to 
the Go ecosystem:
1. GopherJS - a Go compiler that generates JavaScript, supporting nearly 
the entire standard library, with goroutines, channels, etc.
2. WebAssembly code generation for the official Go toolkit.

While other communities will begin the effort to support WebAssembly, 
Richard and friends has already done the job for us to leverage this 
opportunity.

I want to send a big "THANK YOU" to Richard and everybody involved.

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [go-nuts] How to signal(sigint) blocking goroutine

2018-08-10 Thread Tamás Gulácsi
Juct use the same context to your ExecContexts and cancel it on success to make 
the other stop. 

-- 
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] [ANN]: go_generics code template engine for Go that Google was hiding from you :)

2018-08-10 Thread michal


TL;DR you can go-get go_generics - no Bazel needed


go_generics [1] is a tool that was first observed few months back with the 
release of gVisor. It allows for generating code from template while still 
working with standard Go code. It's a great improvement over working with 
Go templates but nothing like C++ templates.


We used it at Scylla to create go-set [2] a replacement for fatih/set [3] 
package. This approach allows for working with plain types instead of 
interface{} thus eliminating "escape to heap" problem and improving 
performance x10 in some cases.


The reason to fork it was a messy build process with Bazel. To streamline 
things for go-set [2] we fixed that so you can now just go-get the tool. 
The tool is universal and can be a good fit in almost any project.


Enjoy!


[1] https://github.com/mmatczuk/go_generics

[2] https://github.com/scylladb/go-set

[3] https://github.com/fatih/set


Michal

-- 
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] [ANN]: go_generics code template engine for Go that Google was hiding from you :)

2018-08-10 Thread michal


TL;DR you can go-get go_generics - no Bazel needed

go_generics [1] is a tool that was first observed few months back with the 
release of gVisor. It allows for generating code from template while still 
working with standard Go code. It's a great improvement over working with 
Go templates but nothing like C++ templates.

We used it at Scylla to create go-set [2] a replacement for fatih/set [3] 
package. This approach allows for working with plain types instead of 
interface{} thus eliminating "escape to heap" problem and improving 
performance x10 in some cases.

The reason to fork it was a messy build process with Bazel. To streamline 
things for go-set [2] we fixed that so you can now just go-get the tool. 
The tool is universal and can be a good fit in almost any project.

Enjoy!

[1] https://github.com/mmatczuk/go_generics

[2] https://github.com/scylladb/go-set

[3] https://github.com/fatih/set

Michal

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[go-nuts] Re: golang + wasm three times slower than javascript?

2018-08-10 Thread peterGo
Kim,

These are not useful results. Exponential recursive algorithms are known to 
be very expensive. Use an iterative algorithm. 

See Fibonacci Numbers and Binomial Coefficients: 
http://citeseerx.ist.psu.edu/viewdoc/download?doi=10.1.1.137.752&rep=rep1&type=pdf

For example,

$ go version
go version devel +9ef5ee911c Tue Aug 7 14:36:14 2018 + linux/amd64
$ go test fib_test.go -bench=.
goos: linux
goarch: amd64
BenchmarkRecursive-4  14617595761 ns/op
BenchmarkIterative-4   500028.2 ns/op

Code: https://play.golang.org/p/zyXqNt3knAM

What results do you get with an iterative algorithm?

Peter

On Friday, August 10, 2018 at 6:28:01 AM UTC-4, netbrain wrote:
>
> So been playing around with go and wasm support on go version devel 
> +479da24aac Fri Aug 10 00:47:31 2018 + linux/amd64
>
> Curious on performance i tried implementing a Fibonacci algorithm function 
> in JS and compared it to it's equivalent in GO. Calculating fib(44) takes 
> 11 seconds on my machine in JS and in GO it takes 36 seconds.
>
> Any idea's to why I would get these results? I know wasm is very much an 
> experimental feature of go, however I expected at least equal to or better 
> performance than JS. Are there any browser optimizations which is running 
> in my JS code which may not be in effect in wasm?
>
> Test code available at 
> https://github.com/netbrain/kata/tree/master/go/wasm
>
> Cheers
> Kim
>

-- 
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 to disable fmt-Error messages

2018-08-10 Thread 'Björn Karge' via golang-nuts


This is a Q&D workaround. A maintenance nightmare, but it works.

Sprintf("Hello"+"%[2]s", "World", "")


On Monday, January 31, 2011 at 7:46:59 PM UTC+8, Ondekoza wrote:
>
> The fmt-package has a convinent error report method. 
>
> According to 
>
> http://golang.org/pkg/fmt/ 
>
> a string printed with fmt.Printf will add 
>
> Too many arguments: %!(EXTRA type=value) 
> Printf("hi", "guys"):  hi%!(EXTRA string=guys) 
>
> to the output if too many variables are supplied. 
>
> Now the following problem: 
>
> I always retrieve three numbers as int's and a string from an external 
> source that I want to print and that is beyond my control - that might 
> or might not contain placeholders for the insertion of the three ints. 
> When I call fmt.Sprintf(mystring, int1, int2, int3) and the number of 
> %-placeholder does not match, I'll get the EXTRA-error. How can I 
> count the number of replacer-items, so that I can call Printf with the 
> correct number of arguments? 
>
> Obviously I cannot count the '%', since the input string might contain 
> '%' signs that are no replacers. Additionally I cannot guarantuee that 
> the string from the external source does not 
> contain '%!'. 
>
> Can I disable/discard the error-message somehow? 
>
> yours 
> Stefan Schroeder 
>

-- 
_Grab is hiring. Learn more at *https://grab.careers 
*_


By communicating with Grab Inc and/or its 
subsidiaries, associate companies and jointly controlled entities (“Grab 
Group”), you are deemed to have consented to processing of your personal 
data as set out in the Privacy Notice which can be viewed at 
https://grab.com/privacy/ 


This email contains 
confidential information and is only for the intended recipient(s). If you 
are not the intended recipient(s), please do not disseminate, distribute or 
copy this email and notify Grab Group immediately if you have received this 
by mistake and delete this email from your system. Email transmission 
cannot be guaranteed to be secure or error-free as any information therein 
could be intercepted, corrupted, lost, destroyed, delayed or incomplete, or 
contain viruses. Grab Group do not accept liability for any errors or 
omissions in the contents of this email arises as a result of email 
transmission. All intellectual property rights in this email and 
attachments therein shall remain vested in Grab Group, unless otherwise 
provided by law.

-- 
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: Go 1.11 Beta 3 is released

2018-08-10 Thread Ken MacDonald
Thanks guys. Inherited this system, and basic "go" worked fine, but had
some GOPATH/PATH issues. Now seems good! - Ken

On Thu, Aug 9, 2018 at 10:29 PM 'Bryan Mills' via golang-nuts <
golang-nuts@googlegroups.com> wrote:

> Did you happen to install it using another go1.11 beta build in module
> mode?
>
> If so, it could have been https://golang.org/issue/26869.
>
>
> On Thursday, August 9, 2018 at 4:35:31 PM UTC-4, Ken MacDonald wrote:
>>
>> Hi,
>> Just attempted to install 1.11beta3. Using the following instructions,
>> the "go get" portion appears to have succeeded, but "go1.11beta3 download"
>> fails with "bash: go1.11beta3: command not found". This worked fine on
>> my Mac, but trying on a CentOS system now. Suggestions welcome.
>>
>>
>>> If you have Go installed already, the easiest way to try go1.11beta3
>>> is by using the go command:
>>> $ go get golang.org/dl/go1.11beta3
>>> $ go1.11beta3 download
>>>
>>>
>>> --
> 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] Help/Suggestions needed for architecture/design of an utility

2018-08-10 Thread akapoor87
 

Since quite some time I have been working on an IaaS Resource Monitoring 
Utility for different clouds (AWS, GCP, Azure, Openstack). Such a utility 
is particularly useful to my team because we develop a 

PaaS product (that gets deployed on all these IaaS platforms) and as a 
result of dev/testing/bugs there are lots of resources that pile up on all 
of these IaaS platforms. This results in increased costs + exhaustion

of quota. Idea behind this utility was to give a overview of a particular 
IaaS account (VMs, Snapshots, Volumes, Object Store Containers etc.) as 
well as support cleanup of such orphan/stale resources.


Now, I feel such a utility could also be useful for other teams/community 
outside our company - hence I intend to open source the Golang utility now. 
The problem is that the code in it's current form has 

reached a stage where we have lot of custom code which is very specific to 
our use-case. Something along the lines of:


i) Mark Volumes as orphans which have a tag 'foo=bar', creation date before 
14 days and status as 'available' or 'error'

ii) Mark Snapshots as orphans which have a description starting with 'foo' 
OR 'foo1' OR 'foo2' etc and don't have a 

iii) Mark Objectstore container files as orphans which have 'foo' somewhere 
in the object name and creation_date should be minimum X days back.


Hope that gives you an idea.



Now, I plan to somehow decouple all this logic and restrict the actual 
tool's code to just interact with the IaaS and report the data (Console 
Output / PDF etc.)

With this, all custom filtering logic has to then move out so that anybody 
who uses this tool can just easily specify his custom logic to mark a 
resource as orphan.


I had some ideas along the following lines:


i) Have a json/yaml configuration file which defines the logic of marking a 
resource as stale/orphan. How/Where would user define his logic ? Some sort 
of DSL ? What if users also need regex support tomorrow ? Will it support 
all combinations that user might want.. < , > , >= , != etc..

ii) Have these filters as part of code itself. Somebody then forks the 
repository and adds some custom Go code which acts as the filter - 
Something around chain of filters pattern ?

iii) Expose all possible filters variations as config/environment 
variables. Probably this won't be a good approach as this would require a 
lot of input to actually use the tool ?


Plan is to keep the tool implementation as thin as possible and all custom 
filters/logic to be easily configurable by the user and not compromising on 
the ease of tool use at the same time.


Any suggestions/help around best practices for such an implementation would 
be really helpful. Please let me know if you need any further information.




Best Regards,

Akshay

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[go-nuts] Re: golang + wasm three times slower than javascript?

2018-08-10 Thread Space A.
Hi Kim,

check this out: 
https://medium.com/gopherjs/surprises-in-gopherjs-performance-4a0a49b04ecd
You will find some comparison of native Go vs C vs GopherJS (and JS itself, 
in general), with surprisingly "fast" JS* and "slow" Go. However the reason 
is not that obvious...

Regards


пятница, 10 августа 2018 г., 13:28:01 UTC+3 пользователь netbrain написал:
>
> So been playing around with go and wasm support on go version devel 
> +479da24aac Fri Aug 10 00:47:31 2018 + linux/amd64
>
> Curious on performance i tried implementing a Fibonacci algorithm function 
> in JS and compared it to it's equivalent in GO. Calculating fib(44) takes 
> 11 seconds on my machine in JS and in GO it takes 36 seconds.
>
> Any idea's to why I would get these results? I know wasm is very much an 
> experimental feature of go, however I expected at least equal to or better 
> performance than JS. Are there any browser optimizations which is running 
> in my JS code which may not be in effect in wasm?
>
> Test code available at 
> https://github.com/netbrain/kata/tree/master/go/wasm
>
> Cheers
> Kim
>

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [go-nuts] How to signal(sigint) blocking goroutine

2018-08-10 Thread Space A.

>
> The first step is to get the idea of signals out of your head.  As I 
> said, you can not send a signal to a goroutine.  It's the wrong 
> approach. 
>
> Instead, create a context.Context value (e.g., context.Background)...
>


Hmm... *Do not communicate by sharing memory; instead, share memory by 
communicating.*


Regards



пятница, 10 августа 2018 г., 7:02:01 UTC+3 пользователь Ian Lance Taylor 
написал:
>
> On Thu, Aug 9, 2018 at 6:51 PM,  > 
> wrote: 
> > 
> > https://play.golang.org/p/mr58JS4WsJV 
> > 
> > Okay, I realize now that I didn't do a very good job in my first post of 
> > explaining my problem, so I'll trying again.  In the above code I need 
> to 
> > signal(sigint or sigterm) the exec.CommandContext on line 69 that is 
> > blocking so it will stop and finish the goroutine.  The goal behind the 
> code 
> > is to set a record duration and then stop the blocking command after the 
> > record timer has been met and exit the goroutine normally.  So far I 
> haven't 
> > been able to figure out how to signal the command to stop.  I have two 
> > tuners that can be recording a the same time, so I need them running in 
> > goroutines so the main thread can do other things.  I read through the 
> > context package that you recommended, but still can't get it to work. 
>
> The first step is to get the idea of signals out of your head.  As I 
> said, you can not send a signal to a goroutine.  It's the wrong 
> approach. 
>
> Instead, create a context.Context value (e.g., context.Background), 
> then pass it to context.WithTimeout or context.WithCancel, then pass 
> the Context to your goroutine.  Have your function periodically check 
> whether context.Err is set.  In some cases this is naturally done by 
> selecting on context.Done along with other channels, in some cases you 
> need to call context.Err every so often.  When you want the goroutine 
> to stop, call the cancel function returned by WithTimeout or 
> WithCancel. 
>
> For more information, see https://blog.golang.org/context . 
>
> Ian 
>
>
>
> > On Wednesday, August 8, 2018 at 12:20:11 AM UTC-4, Ian Lance Taylor 
> wrote: 
> >> 
> >> On Tue, Aug 7, 2018 at 7:02 PM,   wrote: 
> >> > 
> >> > https://play.golang.org/p/d5n9bYmya3r 
> >> > 
> >> > I'm new to the go language and trying to figure out how to sigint a 
> >> > blocking 
> >> > goroutine.  in the playground code I included an infinite for loop to 
> >> > simulate the blocking. In my real world use the for block would be a 
> >> > long 
> >> > running file save from an external device.  I appreciate any advice 
> or 
> >> > direction that is given. 
> >> 
> >> I'm not sure quite what you mean, but in general you can not send a 
> >> signal to a goroutine in Go.  Goroutines are not threads.  If you want 
> >> a goroutine to be interruptible, you must write the goroutine to check 
> >> whether something is trying to interrupt it; the standard library's 
> >> "context" package is often used for this purpose. 
> >> 
> >> 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 . 
> > 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: My trouble about GO interface

2018-08-10 Thread Henry
When designing a Go program, remember that there is no type hierarchy in Go. 
You create the actual Elephant, Tiger, etc., but not Animal since Animal is 
just a classification. 

In my fictional world, I may have Alice, Bob, and Charlie. If I need a banker, 
I just put up an ads with the job specifications. Anybody can apply as long as 
they meet my requirements. If Bob wants to be a banker and yet he doesn't have 
the skills, he needs to train himself until he has what it takes to be a 
banker. This is Go world. There is no need to create a Banker type. You just 
need Alice, Bob, and Charlie.

In some other languages, you need the Banker type. In fact, you may actually 
also need the Person type and create a hierarchy of types. Go doesn't work that 
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.


Re: [go-nuts] How to signal(sigint) blocking goroutine

2018-08-10 Thread nateandjenn
Thanks for all the comments.  I did finally figure it 
out.  https://play.golang.org/p/ghCT6DCDLJz

On lines 69-70 changed that code from and exec.Command to exec.Start 
allowing me to sleep for the desired amount of time and then signal(sigint) 
the command via cmd.Process.Signal(syscall.SIGINT) 

Nate

On Thursday, August 9, 2018 at 9:51:53 PM UTC-4, natea...@gmail.com wrote:
>
> https://play.golang.org/p/mr58JS4WsJV
>
> Okay, I realize now that I didn't do a very good job in my first post of 
> explaining my problem, so I'll trying again.  In the above code I need to 
> signal(sigint or sigterm) the exec.CommandContext on line 69 that is 
> blocking so it will stop and finish the goroutine.  The goal behind the 
> code is to set a record duration and then stop the blocking command after 
> the record timer has been met and exit the goroutine normally.  So far I 
> haven't been able to figure out how to signal the command to stop.  I have 
> two tuners that can be recording a the same time, so I need them running in 
> goroutines so the main thread can do other things.  I read through the 
> context package that you recommended, but still can't get it to work. 
>
> Thanks
>
> On Wednesday, August 8, 2018 at 12:20:11 AM UTC-4, Ian Lance Taylor wrote:
>>
>> On Tue, Aug 7, 2018 at 7:02 PM,   wrote: 
>> > 
>> > https://play.golang.org/p/d5n9bYmya3r 
>> > 
>> > I'm new to the go language and trying to figure out how to sigint a 
>> blocking 
>> > goroutine.  in the playground code I included an infinite for loop to 
>> > simulate the blocking. In my real world use the for block would be a 
>> long 
>> > running file save from an external device.  I appreciate any advice or 
>> > direction that is given. 
>>
>> I'm not sure quite what you mean, but in general you can not send a 
>> signal to a goroutine in Go.  Goroutines are not threads.  If you want 
>> a goroutine to be interruptible, you must write the goroutine to check 
>> whether something is trying to interrupt it; the standard library's 
>> "context" package is often used for this purpose. 
>>
>> Ian 
>>
>

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [go-nuts] How to signal(sigint) blocking goroutine

2018-08-10 Thread Dave Cheney
The context value you pass into record isn't used and running record in its 
own goroutine doesn't really add anything because the main goroutine just 
waits for the other goroutine to exit. The exit the second goroutine will 
be at least 1 second, but could be much longer.

On Saturday, 11 August 2018 12:54:08 UTC+10, natea...@gmail.com wrote:
>
> Thanks for all the comments.  I did finally figure it out.  
> https://play.golang.org/p/ghCT6DCDLJz
>
> On lines 69-70 changed that code from and exec.Command to exec.Start 
> allowing me to sleep for the desired amount of time and then signal(sigint) 
> the command via cmd.Process.Signal(syscall.SIGINT) 
>
> Nate
>
> On Thursday, August 9, 2018 at 9:51:53 PM UTC-4, natea...@gmail.com wrote:
>>
>> https://play.golang.org/p/mr58JS4WsJV
>>
>> Okay, I realize now that I didn't do a very good job in my first post of 
>> explaining my problem, so I'll trying again.  In the above code I need to 
>> signal(sigint or sigterm) the exec.CommandContext on line 69 that is 
>> blocking so it will stop and finish the goroutine.  The goal behind the 
>> code is to set a record duration and then stop the blocking command after 
>> the record timer has been met and exit the goroutine normally.  So far I 
>> haven't been able to figure out how to signal the command to stop.  I have 
>> two tuners that can be recording a the same time, so I need them running in 
>> goroutines so the main thread can do other things.  I read through the 
>> context package that you recommended, but still can't get it to work. 
>>
>> Thanks
>>
>> On Wednesday, August 8, 2018 at 12:20:11 AM UTC-4, Ian Lance Taylor wrote:
>>>
>>> On Tue, Aug 7, 2018 at 7:02 PM,   wrote: 
>>> > 
>>> > https://play.golang.org/p/d5n9bYmya3r 
>>> > 
>>> > I'm new to the go language and trying to figure out how to sigint a 
>>> blocking 
>>> > goroutine.  in the playground code I included an infinite for loop to 
>>> > simulate the blocking. In my real world use the for block would be a 
>>> long 
>>> > running file save from an external device.  I appreciate any advice or 
>>> > direction that is given. 
>>>
>>> I'm not sure quite what you mean, but in general you can not send a 
>>> signal to a goroutine in Go.  Goroutines are not threads.  If you want 
>>> a goroutine to be interruptible, you must write the goroutine to check 
>>> whether something is trying to interrupt it; the standard library's 
>>> "context" package is often used for this purpose. 
>>>
>>> Ian 
>>>
>>

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[go-nuts] Re: golang + wasm three times slower than javascript?

2018-08-10 Thread Agniva De Sarker
>  however I expected at least equal to or better performance than JS.

Hi,

Unfortunately, this expectation is incorrect. Wasm is NOT guaranteed to 
give you better or at least equal performance to javascript. This is even 
in the general case when you run wasm using emcc. The performance is very 
dependant on what you are running and on which browser (sometimes even 
browser versions matter). 

Take a look at this to see how does the performance vary 
- https://takahirox.github.io/WebAssembly-benchmark/.

Coming to Go, 1.11 will just have experimental support. We are just 
focusing on correctness as of now. Also, there are couple of issues in the 
wasm spec itself which impediments a language like Go which needs to unwind 
and restore the call stack when switching between goroutines. This is only 
related to Go though. But even in the general case, wasm performance is not 
always better than javascript. WebAssembly is not a silver bullet.

-Agniva

On Friday, 10 August 2018 15:58:01 UTC+5:30, netbrain wrote:
>
> So been playing around with go and wasm support on go version devel 
> +479da24aac Fri Aug 10 00:47:31 2018 + linux/amd64
>
> Curious on performance i tried implementing a Fibonacci algorithm function 
> in JS and compared it to it's equivalent in GO. Calculating fib(44) takes 
> 11 seconds on my machine in JS and in GO it takes 36 seconds.
>
> Any idea's to why I would get these results? I know wasm is very much an 
> experimental feature of go, however I expected at least equal to or better 
> performance than JS. Are there any browser optimizations which is running 
> in my JS code which may not be in effect in wasm?
>
> Test code available at 
> https://github.com/netbrain/kata/tree/master/go/wasm
>
> Cheers
> Kim
>

-- 
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] Local shared libraries and forks without vendor and GOPATH

2018-08-10 Thread 'meta keule' via golang-nuts

Hi,

if I understand correctly, the plan with versioned packages and modules is 
to deprecate the vendor folder and GOPATH some time after Go 1.11.

Now it is possible to have own shared packages that aren't hosted anywhere, 
just sitting on the harddrive inside GOPATH or the vendor directory. This 
also allows to have modified forks of a third party package and trick the 
Go tool to treat it like the original.

Where am I supposed to store such local packages and forks without using 
GOPATH or vendor directories?

Thank you.

-benny

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