[go-nuts] Re: undefined (type *math/rand.Rand has no field or method randIntn)

2020-02-25 Thread Anjana Prabhakar
Thank you.

On Wednesday, 26 February 2020 01:03:35 UTC+5:30, Jake Montgomery wrote:
>
>
> On Tuesday, February 25, 2020 at 1:42:31 PM UTC-5, Anjana Prabhakar wrote:
>>
>> I get the error as r1.randIntn undefined (type *math/rand.Rand has no 
>> field or method randIntn). Please help.
>>
>
> The message is  pretty clear. The first step I would take with a message 
> like that is to look at the documentation for the type that the compiler 
> has so kindly provided. If you go to the documentation for the rand 
> package , you will see that 
> the Rand struct has no method 'randIntn', just as the message says. The 
> next step would be to read about the methods that are available for 
> rand.Rand, and see if any of them fit your needs. 
>
> (The fact that randIntn starts with a lower case letter is a big hint that 
> there could be no such public method.)
>
> Good Luck
>

-- 
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/67171c6d-63d7-4704-9813-ecc78b3b7174%40googlegroups.com.


Re: [go-nuts] undefined (type *math/rand.Rand has no field or method randIntn)

2020-02-25 Thread Anjana Prabhakar
Thank you.

On Wednesday, 26 February 2020 00:16:29 UTC+5:30, burak serdar wrote:
>
> On Tue, Feb 25, 2020 at 11:42 AM Anjana Prabhakar 
> > wrote: 
> > 
> > Hi All, 
> > 
> > I am trying to generate a random integer using the below code snippet: 
> > package ABC 
> > import ( 
> > * 
> > "math/rand" 
> > ) 
> > func execBlock( 
> > logger log.Logger,) { 
> > var validTxs, invalidTxs, unchkdTxs = 0, 0, 0 
> > 
> > txIndex := 0 
> > proxyCb := func(req *xxx, res *yyy) { 
> > if r, ok := res.Value.(*); ok { 
> > txRes := r.DeliverTx 
> > // code for random integer begin 
> >   s1 := rand.NewSource(time.Now().UnixNano()) 
> > r1 := rand.New(s1) 
> > toCheck := r1.randIntn(100) // getting error for this line 
> > if toCheck <= 65{ 
> > *** 
> > }else { 
> > * 
> > }// end 
> > } 
> > } 
> > } 
> > 
> > I get the error as r1.randIntn undefined (type *math/rand.Rand has no 
> field or method randIntn). Please help. 
>
> It doesn't have randIntn, it has Intn, so use r1.Intn(100) 
>
> > 
> > Thanks, 
> > Anjana 
> > 
> > -- 
> > 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 golan...@googlegroups.com . 
> > To view this discussion on the web visit 
> https://groups.google.com/d/msgid/golang-nuts/5f0fc1e1-3554-4d2d-b7e4-0fbc196e1b53%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/4ad14437-126f-43ed-bec4-7c9742d2d4b2%40googlegroups.com.


Re: [go-nuts] Fuchsia Programming Language Policy

2020-02-25 Thread Jon Conradt
It is nice to see the clarification. I can understand not using a GC 
language in the OS, but the previous wording did sound like it was 
unwelcome in their user land tools. 

Progress in getting their port of Go into the CI system would be 
encouraging. 

Jon

On Tuesday, February 25, 2020 at 8:45:34 PM UTC-8, Ian Lance Taylor wrote:
>
> On Tue, Feb 25, 2020 at 9:22 AM Jon Conradt  > wrote: 
> > 
> > The Fuchsia Programming Language Policy gives some insight into the 
> experience the Fuchsia team has had with Go, and it doesn't sound good. 
> > 
> > "The Fuchsia Platform Source Tree has had negative implementation 
> experience using Go. The system components the Fuchsia project has built in 
> Go have used more memory and kernel resources than their counterparts (or 
> replacements) the Fuchsia project has built using C++ or Rust." 
> > 
> > 
> > The Fuchsia Platform Source tree is defined as "The Fuchsia Platform 
> Source Tree is the source code hosted on fuchsia.googlesource.com." 
> > 
> > Their conclusion, and each language has some issues is pretty severe. 
> > 
> > Go is not approved, with the following exceptions: 
> > 
> > netstack. Migrating netstack to another language would require a 
> significant investment. In the fullness of time, we should migrate netstack 
> to an approved language. 
> > 
> > All other uses of Go in Fuchsia for production software on the target 
> device must be migrated to an approved language. 
> > 
> >  That's a shame. I was hoping that Fuchsia would provide a way for Go to 
> have a nice GUI. 
> > 
> > Two of the issues listed as cons include the toolchain producing 'large 
> binaries' and the related issue of their being a 'substantial runtime.' It 
> seems to me that both of these issues can be addressed through some of the 
> techniques used to build tiny Docker images from Go, but I suspect they 
> would like to have a much simpler route, e.g. a go build flag. 
>
> To be clear, the Fuchsia project has decided to not use Go in the 
> development of Fuchsia itself.  You can still run Go programs on 
> Fuchsia.  See https://fuchsia-review.googlesource.com/c/fuchsia/+/367414 
> which tries to clarify this.  That said I haven't seen much recently 
> about adding the Go port of Fuchsia to the main Go repo. 
>
> 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/f6c715c2-e708-453d-8d83-2399c3859d35%40googlegroups.com.


Re: [go-nuts] Fuchsia Programming Language Policy

2020-02-25 Thread Ian Lance Taylor
On Tue, Feb 25, 2020 at 9:22 AM Jon Conradt  wrote:
>
> The Fuchsia Programming Language Policy gives some insight into the 
> experience the Fuchsia team has had with Go, and it doesn't sound good.
>
> "The Fuchsia Platform Source Tree has had negative implementation experience 
> using Go. The system components the Fuchsia project has built in Go have used 
> more memory and kernel resources than their counterparts (or replacements) 
> the Fuchsia project has built using C++ or Rust."
>
>
> The Fuchsia Platform Source tree is defined as "The Fuchsia Platform Source 
> Tree is the source code hosted on fuchsia.googlesource.com."
>
> Their conclusion, and each language has some issues is pretty severe.
>
> Go is not approved, with the following exceptions:
>
> netstack. Migrating netstack to another language would require a significant 
> investment. In the fullness of time, we should migrate netstack to an 
> approved language.
>
> All other uses of Go in Fuchsia for production software on the target device 
> must be migrated to an approved language.
>
>  That's a shame. I was hoping that Fuchsia would provide a way for Go to have 
> a nice GUI.
>
> Two of the issues listed as cons include the toolchain producing 'large 
> binaries' and the related issue of their being a 'substantial runtime.' It 
> seems to me that both of these issues can be addressed through some of the 
> techniques used to build tiny Docker images from Go, but I suspect they would 
> like to have a much simpler route, e.g. a go build flag.

To be clear, the Fuchsia project has decided to not use Go in the
development of Fuchsia itself.  You can still run Go programs on
Fuchsia.  See https://fuchsia-review.googlesource.com/c/fuchsia/+/367414
which tries to clarify this.  That said I haven't seen much recently
about adding the Go port of Fuchsia to the main Go repo.

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/CAOyqgcWndf4h4y%3DU%3DqbSZeGmanVrFryLTO5UntpPJcO5FkbGKA%40mail.gmail.com.


[go-nuts] Re: Fuchsia Programming Language Policy

2020-02-25 Thread G Shields
They made a political decision,
Not supporting GO in the new OS or a GO GUI is a show stopper.

After Unladen Swallow and others https://killedbygoogle.com/

I am, No longer interested in GO

On Tuesday, February 25, 2020 at 9:22:11 AM UTC-8, Jon Conradt wrote:
>
> The Fuchsia Programming Language Policy 
> 
>  gives 
> some insight into the experience the Fuchsia team has had with Go, and it 
> doesn't sound good.
>
> "The Fuchsia Platform Source Tree has had negative implementation 
> experience using Go. The system components the Fuchsia project has built in 
> Go have used more memory and kernel resources than their counterparts (or 
> replacements) the Fuchsia project has built using C++ or Rust."
>
>
> The Fuchsia Platform Source tree is defined as "The *Fuchsia Platform 
> Source Tree* is the source code hosted on fuchsia.googlesource.com."
>
> Their conclusion, and each language has some issues is pretty severe.
>
>- Go is not approved, with the following exceptions:
>   - *netstack*. Migrating netstack to another language would require 
>   a significant investment. In the fullness of time, we should migrate 
>   netstack to an approved language.
>- All other uses of Go in Fuchsia for production software on the 
>target device must be migrated to an approved language.
>
>  That's a shame. I was hoping that Fuchsia would provide a way for Go to 
> have a nice GUI.
>
> Two of the issues listed as cons include the toolchain producing 'large 
> binaries' and the related issue of their being a 'substantial runtime.' It 
> seems to me that both of these issues can be addressed through some of the 
> techniques used to build tiny Docker images from Go, but I suspect they 
> would like to have a much simpler route, e.g. a go build flag.
>
> Jon
>

-- 
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/8cab09c2-58a0-4fef-95bf-f584a663e9ae%40googlegroups.com.


Re: [go-nuts] Converting *byte to unsafe.Pointer and back to *byte

2020-02-25 Thread robert engels
Maybe an artifact of the C to Go automatic translation tool.

> On Feb 25, 2020, at 5:29 PM, 'Keith Randall' via golang-nuts 
>  wrote:
> 
> 
> 
> On Tuesday, February 25, 2020 at 4:10:46 AM UTC-8 dmitry@jetbrains.com 
> wrote:
> What is the meaning of the conversion
> 
> var b []byte
> var p *byte = (*byte)(unsafe.Pointer(*b[0]))
> 
> You mean [0] at the end there, not *b[0].
>  
> 
> It is used for example in 
> https://github.com/golang/net/blob/master/internal/socket/iovec_64bit.go 
> .
> 
> How it is different from
> 
> var b []byte
> var p *byte = [0]
> 
> 
> It is not any different. Not sure why the code goes through that hoop 
> unnecessarily.
> Probably historical accident. Maybe go through the change history and see how 
> it evolved.
>  
> Thank 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/68ad8286-1bcf-4706-ad4c-f33147387c2e%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/3524F563-40BD-4FAA-B1FC-6CD84E9AF564%40ix.netcom.com.


[go-nuts] Re: Go 1.14 is released

2020-02-25 Thread Juan Vargas
Mil Gracias Carlos. Juan


On Tue, Feb 25, 2020 at 4:41 PM Carlos Amedee  wrote:

> Hello gophers,
>
> We just released Go 1.14.
>
> To find out what has changed in Go 1.14, read the release notes:
> https://golang.org/doc/go1.14
>
> You can download binary and source distributions from our download page:
> https://golang.org/dl/
>
> If you have Go installed already, an easy way to try go1.14
> is by using the go command:
> $ go get golang.org/dl/go1.14
> $ go1.14 download
>
> To compile from source using a Git clone, update to the release with
> "git checkout go1.14" and build as usual.
>
> Thanks to everyone who contributed to the release!
>
> Cheers,
> Carlos and Dmitri for the Go Team
>
> --
> You received this message because you are subscribed to the Google Groups
> "golang-announce" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to golang-announce+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/golang-announce/CAD7Aq3RLzg1fe_eyqVUPkkyTRV_5OZ%2BBO6iVakx1QShZCbhtwA%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/CALM%2BC%2B9YbeXVMr89QPi5_iGXq--rSRp5VK3f49Lt%3DR34a__u-w%40mail.gmail.com.


[go-nuts] Unable to pull Golang 1.14-alpine3.11 using Docker

2020-02-25 Thread Sean Farrow
Hi,

I'm having an issue whilst attempting to pull the Docker image 
golang:1.14.0-alpine3.11 using version 2.2.0.3 (with Docker engine 19.03.5) of 
Docker for windows.

I get the response that there is no matching manifest for linux/amd64 in the 
manifest list.

I am able to pull 1.13.8-alpine3.11, so wondered whether something was amiss?

This is all using Docker for windows running using Linux containers.

Any help appreciated.

Thanks,
Sean.

-- 
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/DB7PR05MB5659F4E0E89B6C1DB31D3A77C6EA0%40DB7PR05MB5659.eurprd05.prod.outlook.com.


[go-nuts] how to dynamic define a member in struct

2020-02-25 Thread Zhihong GUO
Hello all,

I am using mongo-go-driver to replace globalsign-mgo, I want to write a new 
module for mongo-go instead of changing directly the existing module 
running on globalsign-mgo.

I facing a problem, there is a common data structure defined as below:

type Meeting struct {
// Id of the Meeting
ID bson.ObjectId `json:"id,omitempty" bson:"_id,omitempty"`
// UserId is the owner of the Meeting
UserID bson.ObjectId `json:"user_id,omitempty" bson:"user_id,omitempty"`
}

where the bson.ObjectId is defined in globalsign.mgo, but in the 
mongo-driver, it should be *primitive.bson.ObjectID, defined 
in "go.mongodb.org/mongo-driver/bson/primitive".

So when I make the object of Meeting from protobuf, if I using 
mongo-driver, the code looks like:

// FromProto buils a Meeting model from corresponding prototype
func FromProto(proto *proto.Meeting) *Meeting {
model := Meeting{}

if proto.Id != "" {
model.ID, _ = primitive.ObjectIDFromHex(proto.Id)
} else {
model.ID = primitive.NewObjectID()
}
model.UserID, _ = primitive.ObjectIDFromHex(proto.UserId)
   return 
}

It looks the Meeting and the related operation code have to be deep coupled 
with either globalsign or mongo-driver. 
If I add a new Meeting struct for mongo-driver, a lot of code need to add 
or modify. Is there any way to dynamic switch the bson between globalsign 
and mongo-driver, so that the Meeting structure be compliant with two 
modules?

Thanks,

James

-- 
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/9575e90a-1249-4229-baee-083e7986ef55%40googlegroups.com.


Re: [go-nuts] Understind how to apply timeout using gouritine

2020-02-25 Thread Juan Mamani
Hi Michel,

I've tried your sample with this result:

2020/02/25 23:12:51.854561 Stop in 2s
2020/02/25 23:12:51.854710 Hey!
2020/02/25 23:12:57.854967 Bye Bye!

But function still running."Bye Bye" appeared  +6s later.   I will check 
Context package as you recomended me.
Thanks!

El martes, 25 de febrero de 2020, 5:43:00 (UTC-3), Michel Levieux escribió:
>
> Hi Juan,
>
> You cannot terminate a function execution from its caller if you did not 
> pass it an argument (most likely a channel) which it can use to communicate 
> with its caller, and terminate itself when the timeout is reached.
> The simplest example I can think of is the following: 
> https://play.golang.org/p/KVQ7uhiWr7H, though I'm not quite sure this is 
> your question, since it looks like you've already experimented with this 
> construct.
>
> You can trick with signals and other constructs but channels are designed 
> for that kind of need, so I suppose this is the best way to go. If you want 
> something that wraps this behaviour because you need the timeout to follow 
> the logic of your program, maybe package https://golang.org/pkg/context/ 
> can help you.
>
> Hope this was useful!
>
> Le mar. 25 févr. 2020 à 00:45, Juan Mamani  > a écrit :
>
>> Sorry again.   Well, I followed your advice. Here is the link 
>> https://play.golang.org/p/7DigEVsKbdx
>> How can I cancel goToSleep() when timeout is reached?
>>
>>
>> El lunes, 24 de febrero de 2020, 14:16:32 (UTC-3), Jake Montgomery 
>> escribió:
>>>
>>> Your code will still not compile. In this group, it is often helpful to 
>>> include a link to your code in the playground (https://play.golang.org/) 
>>> using the "Share" button. That is in addition to, or instead of, posting 
>>> your code in the message. This will allow others to easily run your code, 
>>> but also will allow you to make sure it compiles. 
>>>
>>> On Monday, February 24, 2020 at 10:01:01 AM UTC-5, Juan Mamani wrote:

 Sorry}, here is the right code:  ( just was the effect to b working til 
 At 5:20am  sleepy and lost)

 Expected behaviour is  to end  anonyimous func when  3s timeout is 
 reached.

 //
 package main

 import(
 //"fmt"
 "time"
 "math/rand"
 "log"
 )

 func main(){

  for{
log.Println("-Start")
Task()
log.Println("-End")

   }

 }


 // Trying to adapt from Concurrency in Go by Katherine Cox-Buday
 func Task(){

 doWork := func(  done <-chan interface{}, strings <-chan string, ) 
 <-chan interface{} { //1
 terminated := make(chan interface{})
 go func() {
 defer log.Println("doWork exited.")
 defer close(terminated)
 for {
 goToSleep()
 select {
  //case s := <-strings:
  // case s := ran():
 // Do something interesting
 //fmt.Println(s)
 case <-done: //2
 return
 }
 }
 }()
 return terminated
 }

 done := make(chan interface{})
 terminated := doWork(done, nil)

 go func() { //3
 // Cancel the operation after 3 second.
 time.Sleep(3 * time.Second)
 log.Println("Canceling doWork goroutine reach 3s...")
 close(done)
 }()

 <-terminated //4
 log.Println("Done.")
 }

 done := make(chan interface{})
 terminated := doWork(done, nil)

 go func() { //3
 // Cancel the operation after 3 second.
 time.Sleep(3 * time.Second)
 log.Println("Canceling doWork goroutine reach 3s...")
 close(done)
 }()

 <-terminated //4
 log.Println("Done.")
 }



 func goToSleep(){
 

  

  
  
 rand.Seed(time.Now().UnixNano())
 n := rand.Intn(12) // n will be between 0 and 10
 log.Println("Sleeping ",n,"seconds..")
 time.Sleep(time.Duration(n)*time.Second)
 log.Println("Done sleeping!")
 }

 //



 El lunes, 24 de febrero de 2020, 6:09:09 (UTC-3), Lutz Horn escribió:
>
> > I've tried to adapt from from "Concurrency in Go by Katherine 
> Cox-Buday" to 
> > understand how to apply timeout. But I don't get it. 
>
> What are you trying to do? What is the expected behaviour, what 
> happens instead? 
>
> BTW, this code does not compile, there are same unbalanced curly 
> brackets. 
>
> Lutz 
>
 -- 
>> 

Re: [go-nuts] Understind how to apply timeout using gouritine

2020-02-25 Thread Juan Mamani
Ok, you are right.  But I was confused with this:

2009/11/10 23:00:00 -Start
2009/11/10 23:00:00 Sleeping  8 seconds..2009/11/10 23:00:03 Canceling doWork 
goroutine reach 3s...2009/11/10 23:00:08 Done sleeping!
2009/11/10 23:00:08 doWork exited.
2009/11/10 23:00:08 Done.
2009/11/10 23:00:08 -End
My previous questions were: How can I cancel execution of goToSleep() function? 
 How can I break it? Because I expect  code to stop function gotoTosleep()  at 
3s, but I saw still running at 8s because prints "Done sleeping!"..

But Michael Levieux got the idea and repliedr:"You cannot terminate a function 
execution from its caller.." .  So I was wrong in my understanding how to 
implement "cancel" or "break" goroutinea.


El martes, 25 de febrero de 2020, 13:45:03 (UTC-3), Jake Montgomery 
escribió:
>
> Expected behaviour is  to end  anonyimous func when  3s timeout is reached.
>>
>
> So what is the problem? The whole thing *does *exit after 3 seconds. Of 
> course, your main() is a loop, so it starts again. 
>
> 2009/11/10 23:00:00 -Start
> 2009/11/10 23:00:03 Canceling doWork goroutine reach 3s...
> 2009/11/10 23:00:03 doWork exited.
> 2009/11/10 23:00:03 Done.
> 2009/11/10 23:00:03 -End
>
>
> What exactly did you expect to see other than that?
>
> On Monday, February 24, 2020 at 6:45:26 PM UTC-5, Juan Mamani wrote:
>>
>> Sorry again.   Well, I followed your advice. Here is the link 
>> https://play.golang.org/p/7DigEVsKbdx
>> How can I cancel goToSleep() when timeout is reached?
>>
>>
>> El lunes, 24 de febrero de 2020, 14:16:32 (UTC-3), Jake Montgomery 
>> escribió:
>>>
>>> Your code will still not compile. In this group, it is often helpful to 
>>> include a link to your code in the playground (https://play.golang.org/) 
>>> using the "Share" button. That is in addition to, or instead of, posting 
>>> your code in the message. This will allow others to easily run your code, 
>>> but also will allow you to make sure it compiles. 
>>>
>>> On Monday, February 24, 2020 at 10:01:01 AM UTC-5, Juan Mamani wrote:

 Sorry}, here is the right code:  ( just was the effect to b working til 
 At 5:20am  sleepy and lost)

 Expected behaviour is  to end  anonyimous func when  3s timeout is 
 reached.

 //
 package main

 import(
 //"fmt"
 "time"
 "math/rand"
 "log"
 )

 func main(){

  for{
log.Println("-Start")
Task()
log.Println("-End")

   }

 }


 // Trying to adapt from Concurrency in Go by Katherine Cox-Buday
 func Task(){

 doWork := func(  done <-chan interface{}, strings <-chan string, ) 
 <-chan interface{} { //1
 terminated := make(chan interface{})
 go func() {
 defer log.Println("doWork exited.")
 defer close(terminated)
 for {
 goToSleep()
 select {
  //case s := <-strings:
  // case s := ran():
 // Do something interesting
 //fmt.Println(s)
 case <-done: //2
 return
 }
 }
 }()
 return terminated
 }

 done := make(chan interface{})
 terminated := doWork(done, nil)

 go func() { //3
 // Cancel the operation after 3 second.
 time.Sleep(3 * time.Second)
 log.Println("Canceling doWork goroutine reach 3s...")
 close(done)
 }()

 <-terminated //4
 log.Println("Done.")
 }

 done := make(chan interface{})
 terminated := doWork(done, nil)

 go func() { //3
 // Cancel the operation after 3 second.
 time.Sleep(3 * time.Second)
 log.Println("Canceling doWork goroutine reach 3s...")
 close(done)
 }()

 <-terminated //4
 log.Println("Done.")
 }



 func goToSleep(){
 

  

  
  
 rand.Seed(time.Now().UnixNano())
 n := rand.Intn(12) // n will be between 0 and 10
 log.Println("Sleeping ",n,"seconds..")
 time.Sleep(time.Duration(n)*time.Second)
 log.Println("Done sleeping!")
 }

 //



 El lunes, 24 de febrero de 2020, 6:09:09 (UTC-3), Lutz Horn escribió:
>
> > I've tried to adapt from from "Concurrency in Go by Katherine 
> Cox-Buday" to 
> > understand how to apply timeout. But I don't get it. 
>
> What are you trying to do? What is the expected 

Re: [go-nuts] Understind how to apply timeout using gouritine

2020-02-25 Thread Juan Mamani
Reallly thanks for your help and guide!

El martes, 25 de febrero de 2020, 5:45:17 (UTC-3), Michel Levieux escribió:
>
> Edit: I said "communicate with its caller" but in practice it might as 
> well be another goroutine or the caller of the caller, either way the 
> construct and the logic standing behind it are exactly the same :)
>
> Le mar. 25 févr. 2020 à 09:42, Michel Levieux  > a écrit :
>
>> Hi Juan,
>>
>> You cannot terminate a function execution from its caller if you did not 
>> pass it an argument (most likely a channel) which it can use to communicate 
>> with its caller, and terminate itself when the timeout is reached.
>> The simplest example I can think of is the following: 
>> https://play.golang.org/p/KVQ7uhiWr7H, though I'm not quite sure this is 
>> your question, since it looks like you've already experimented with this 
>> construct.
>>
>> You can trick with signals and other constructs but channels are designed 
>> for that kind of need, so I suppose this is the best way to go. If you want 
>> something that wraps this behaviour because you need the timeout to follow 
>> the logic of your program, maybe package https://golang.org/pkg/context/ 
>> can help you.
>>
>> Hope this was useful!
>>
>> Le mar. 25 févr. 2020 à 00:45, Juan Mamani > > a écrit :
>>
>>> Sorry again.   Well, I followed your advice. Here is the link 
>>> https://play.golang.org/p/7DigEVsKbdx
>>> How can I cancel goToSleep() when timeout is reached?
>>>
>>>
>>> El lunes, 24 de febrero de 2020, 14:16:32 (UTC-3), Jake Montgomery 
>>> escribió:

 Your code will still not compile. In this group, it is often helpful to 
 include a link to your code in the playground (https://play.golang.org/) 
 using the "Share" button. That is in addition to, or instead of, posting 
 your code in the message. This will allow others to easily run your code, 
 but also will allow you to make sure it compiles. 

 On Monday, February 24, 2020 at 10:01:01 AM UTC-5, Juan Mamani wrote:
>
> Sorry}, here is the right code:  ( just was the effect to b working 
> til At 5:20am  sleepy and lost)
>
> Expected behaviour is  to end  anonyimous func when  3s timeout is 
> reached.
>
> //
> package main
>
> import(
> //"fmt"
> "time"
> "math/rand"
> "log"
> )
>
> func main(){
>
>  for{
>log.Println("-Start")
>Task()
>log.Println("-End")
>
>   }
>
> }
>
>
> // Trying to adapt from Concurrency in Go by Katherine Cox-Buday
> func Task(){
>
> doWork := func(  done <-chan interface{}, strings <-chan string, ) 
> <-chan interface{} { //1
> terminated := make(chan interface{})
> go func() {
> defer log.Println("doWork exited.")
> defer close(terminated)
> for {
> goToSleep()
> select {
>  //case s := <-strings:
>  // case s := ran():
> // Do something interesting
> //fmt.Println(s)
> case <-done: //2
> return
> }
> }
> }()
> return terminated
> }
>
> done := make(chan interface{})
> terminated := doWork(done, nil)
>
> go func() { //3
> // Cancel the operation after 3 second.
> time.Sleep(3 * time.Second)
> log.Println("Canceling doWork goroutine reach 3s...")
> close(done)
> }()
>
> <-terminated //4
> log.Println("Done.")
> }
>
> done := make(chan interface{})
> terminated := doWork(done, nil)
>
> go func() { //3
> // Cancel the operation after 3 second.
> time.Sleep(3 * time.Second)
> log.Println("Canceling doWork goroutine reach 3s...")
> close(done)
> }()
>
> <-terminated //4
> log.Println("Done.")
> }
>
>
>
> func goToSleep(){
>   
>   
>   
>   
>   
>
> rand.Seed(time.Now().UnixNano())
> n := rand.Intn(12) // n will be between 0 and 10
> log.Println("Sleeping ",n,"seconds..")
> time.Sleep(time.Duration(n)*time.Second)
> log.Println("Done sleeping!")
> }
>
> //
>
>
>
> El lunes, 24 de febrero de 2020, 6:09:09 (UTC-3), Lutz Horn escribió:
>>
>> > I've tried to adapt from from "Concurrency in Go by Katherine 
>> Cox-Buday" to 
>> > understand how to apply timeout. But I don't get it. 
>>
>> What are you trying to do? What is 

[go-nuts] Re: Converting *byte to unsafe.Pointer and back to *byte

2020-02-25 Thread 'Keith Randall' via golang-nuts


On Tuesday, February 25, 2020 at 4:10:46 AM UTC-8 dmitry@jetbrains.com 
wrote:

> What is the meaning of the conversion
>
> var b []byte
> var p *byte = (*byte)(unsafe.Pointer(*b[0]))
>

You mean [0] at the end there, not *b[0].
 

>
> It is used for example in 
> https://github.com/golang/net/blob/master/internal/socket/iovec_64bit.go.
>
> How it is different from
>
> var b []byte
> var p *byte = [0]
>
>
It is not any different. Not sure why the code goes through that hoop 
unnecessarily.
Probably historical accident. Maybe go through the change history and see 
how it evolved.
 

> Thank 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/68ad8286-1bcf-4706-ad4c-f33147387c2e%40googlegroups.com.


[go-nuts] Re: [ANN] Renderview v0.1.0 with go mod, Gio, and Fyne support

2020-02-25 Thread howardcshaw
I worked it out, will update the programs later. It was not that the events 
were missing - once I enabled the good old Printf debugger, I saw that the 
events are flowing fine. The issue is that on Linux, every Move Mouse event 
reflected what buttons were pressed the entire time they were pressed. On 
Windows, only the Press Mouse event included a value for the Button that 
was pressed (i.e. pointer.ButtonLeft).  

mouse pos({Move Mouse 0 Shared 863h55m54.282s  false {637 369} {0 0} }) 
false
mouse pos({Press Mouse 0 Shared 863h55m54.425s ButtonLeft false {637 369} 
{0 0} }) true
mouse down left({Press Mouse 0 Shared 863h55m54.425s ButtonLeft false {637 
369} {0 0} })
mouse pos({Move Mouse 0 Shared 863h55m54.515s  false {638 369} {0 0} }) 
false
mouse pos({Move Mouse 0 Shared 863h55m54.535s  false {639 369} {0 0} }) 
false
mouse pos({Move Mouse 0 Shared 863h55m54.555s  false {642 369} {0 0} }) 
false
Dragging.
mouse pos({Move Mouse 0 Shared 863h55m54.572s  false {645 370} {0 0} }) 
false
mouse pos({Move Mouse 0 Shared 863h55m54.59s  false {648 370} {0 0} }) false

My code was detecting the return to 0 as the mouse button no longer being 
pressed.

Howard

-- 
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/cd2a324e-e8e9-4c32-b5ab-e96ff6842fff%40googlegroups.com.


Re: [go-nuts] Fuchsia Programming Language Policy

2020-02-25 Thread Jesper Louis Andersen
On Tue, Feb 25, 2020 at 6:22 PM Jon Conradt  wrote:

> The Fuchsia Programming Language Policy
> 
>  gives
> some insight into the experience the Fuchsia team has had with Go, and it
> doesn't sound good.
>
> "The Fuchsia Platform Source Tree has had negative implementation
> experience using Go. The system components the Fuchsia project has built in
> Go have used more memory and kernel resources than their counterparts (or
> replacements) the Fuchsia project has built using C++ or Rust."
>
>
>
This shouldn't be unexpected. It is the trade-off you make with a garbage
collector.

However, it should also be quantified. 33%-40% extra memory usage is
likely. 800% isn't, and would suppose there are structural problems with
the program.

If it is merely a qualitative assessment, then it falls into the category
of subjective opinion. This may be relevant, but it isn't healthy goal
setting. It would have been better if you had "Go programs we wrote
routinely use 200% of the memory of comparable C++ programs. This is too
much, and we can only accept an increase of 20%." Because then the whole
thing is actionable.

The Go garbage collector's pause times is a good example of such an
approach. Start with a conservative goal. Achieve that. Then improve it
over time.

Any program has a bar resource-wise. If you can jump over it, you should
accept the win. Moving the bar continually is usually a bad sign, in my
opinion, since the rules are now up for interpretation outside of your
direct control. So once you demonstrate you can jump high enough, it will
just be moved up a tad so you can't. "Der Prozeß" comes to mind :)

-- 
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/CAGrdgiUFc%2BppEB4KDkGtq_sKWg41Qpv7Hgcs4SVYYB7UYhvsAw%40mail.gmail.com.


Re: [go-nuts] Fuchsia Programming Language Policy

2020-02-25 Thread andrey mirtchovski
my take:
- c++ programmers are going to c++ program. film at 11 (rob pike had a
talk about that)
- dart has UI
- rust is fashionable, but scary (if you've done rust you'll know why)

yes, go was touted as a systems programming language, but it meant
"distributed systems". had that been made clear from the beginning all
this strife would've disappeared. u-root.org shows that go can be used
at firmware level quite handily.

On Tue, Feb 25, 2020 at 2:05 PM Manlio Perillo  wrote:
>
> And the one that is good at both memory management and concurrency has 
> properties of the language that are not yet well-understood.
>
>
> Manlio
>
> On Tuesday, February 25, 2020 at 7:21:00 PM UTC+1, Michael Jones wrote:
>>
>> Actually, you should read the whole note -- it's fun. Half of the languages 
>> are bad because of memory leaks, the other half are bad because of having 
>> GC; half are bad because of difficult asynchronism, the other half are bad 
>> because of having a runtime. etc.
>>
>> It reads like an imperiously-worded tautology about safety/power/convenience 
>> coming at a cost.
>>
>> On Tue, Feb 25, 2020 at 9:51 AM Mohamed Yousif  wrote:
>>>
>>> It seems they are betting high on Dart/flutter and their front end is 
>>> already written with flutter. The assessment seems to be pretty much the 
>>> same as for Dart.
>>>
>>> Dart won with the ui side, while go was competing with C.
>>>
>>> On Tue, 25 Feb 2020 at 7:22 PM, Jon Conradt  wrote:

 The Fuchsia Programming Language Policy gives some insight into the 
 experience the Fuchsia team has had with Go, and it doesn't sound good.

 "The Fuchsia Platform Source Tree has had negative implementation 
 experience using Go. The system components the Fuchsia project has built 
 in Go have used more memory and kernel resources than their counterparts 
 (or replacements) the Fuchsia project has built using C++ or Rust."


 The Fuchsia Platform Source tree is defined as "The Fuchsia Platform 
 Source Tree is the source code hosted on fuchsia.googlesource.com."

 Their conclusion, and each language has some issues is pretty severe.

 Go is not approved, with the following exceptions:

 netstack. Migrating netstack to another language would require a 
 significant investment. In the fullness of time, we should migrate 
 netstack to an approved language.

 All other uses of Go in Fuchsia for production software on the target 
 device must be migrated to an approved language.

  That's a shame. I was hoping that Fuchsia would provide a way for Go to 
 have a nice GUI.

 Two of the issues listed as cons include the toolchain producing 'large 
 binaries' and the related issue of their being a 'substantial runtime.' It 
 seems to me that both of these issues can be addressed through some of the 
 techniques used to build tiny Docker images from Go, but I suspect they 
 would like to have a much simpler route, e.g. a go build flag.

 Jon

 --
 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 golan...@googlegroups.com.
 To view this discussion on the web visit 
 https://groups.google.com/d/msgid/golang-nuts/7778a387-f1f5-4ed0-8453-5b811bac4a6d%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 golan...@googlegroups.com.
>>> To view this discussion on the web visit 
>>> https://groups.google.com/d/msgid/golang-nuts/CAHrL7wHqJnDnEVe4%3D--%3DcSW9oA-eYxcbKagESdZHgSkrdLutpA%40mail.gmail.com.
>>
>>
>>
>> --
>> Michael T. Jones
>> michae...@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/a5227da6-c1ee-4754-95c4-c6bb1dd2d40f%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/CAK4xykW0cA8SwcDBthoAuPtuYajsEozkSRrS1uH3dC8yNWBQng%40mail.gmail.com.


[go-nuts] Go 1.14 is released

2020-02-25 Thread Carlos Amedee
Hello gophers,

We just released Go 1.14.

To find out what has changed in Go 1.14, read the release notes:
https://golang.org/doc/go1.14

You can download binary and source distributions from our download page:
https://golang.org/dl/

If you have Go installed already, an easy way to try go1.14
is by using the go command:
$ go get golang.org/dl/go1.14
$ go1.14 download

To compile from source using a Git clone, update to the release with
"git checkout go1.14" and build as usual.

Thanks to everyone who contributed to the release!

Cheers,
Carlos and Dmitri for the Go Team

-- 
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/CAD7Aq3RLzg1fe_eyqVUPkkyTRV_5OZ%2BBO6iVakx1QShZCbhtwA%40mail.gmail.com.


Re: [go-nuts] Fuchsia Programming Language Policy

2020-02-25 Thread Manlio Perillo
And the one that is good at both memory management and concurrency 
has properties of the language that are not yet well-understood.


Manlio

On Tuesday, February 25, 2020 at 7:21:00 PM UTC+1, Michael Jones wrote:
>
> Actually, you should read the whole note -- it's fun. Half of the 
> languages are bad because of memory leaks, the other half are bad because 
> of having GC; half are bad because of difficult asynchronism, the other 
> half are bad because of having a runtime. etc. 
>
> It reads like an imperiously-worded tautology about 
> safety/power/convenience coming at a cost.
>
> On Tue, Feb 25, 2020 at 9:51 AM Mohamed Yousif  > wrote:
>
>> It seems they are betting high on Dart/flutter and their front end is 
>> already written with flutter. The assessment seems to be pretty much the 
>> same as for Dart.
>>
>> Dart won with the ui side, while go was competing with C. 
>>
>> On Tue, 25 Feb 2020 at 7:22 PM, Jon Conradt > > wrote:
>>
>>> The Fuchsia Programming Language Policy 
>>> 
>>>  gives 
>>> some insight into the experience the Fuchsia team has had with Go, and it 
>>> doesn't sound good.
>>>
>>> "The Fuchsia Platform Source Tree has had negative implementation 
>>> experience using Go. The system components the Fuchsia project has built in 
>>> Go have used more memory and kernel resources than their counterparts (or 
>>> replacements) the Fuchsia project has built using C++ or Rust."
>>>
>>>
>>> The Fuchsia Platform Source tree is defined as "The *Fuchsia Platform 
>>> Source Tree* is the source code hosted on fuchsia.googlesource.com."
>>>
>>> Their conclusion, and each language has some issues is pretty severe.
>>>
>>>- Go is not approved, with the following exceptions:
>>>   - *netstack*. Migrating netstack to another language would 
>>>   require a significant investment. In the fullness of time, we should 
>>>   migrate netstack to an approved language.
>>>- All other uses of Go in Fuchsia for production software on the 
>>>target device must be migrated to an approved language.
>>>
>>>  That's a shame. I was hoping that Fuchsia would provide a way for Go to 
>>> have a nice GUI.
>>>
>>> Two of the issues listed as cons include the toolchain producing 'large 
>>> binaries' and the related issue of their being a 'substantial runtime.' It 
>>> seems to me that both of these issues can be addressed through some of the 
>>> techniques used to build tiny Docker images from Go, but I suspect they 
>>> would like to have a much simpler route, e.g. a go build flag.
>>>
>>> Jon
>>>
>>> -- 
>>> 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 golan...@googlegroups.com .
>>> To view this discussion on the web visit 
>>> https://groups.google.com/d/msgid/golang-nuts/7778a387-f1f5-4ed0-8453-5b811bac4a6d%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 golan...@googlegroups.com .
>> To view this discussion on the web visit 
>> https://groups.google.com/d/msgid/golang-nuts/CAHrL7wHqJnDnEVe4%3D--%3DcSW9oA-eYxcbKagESdZHgSkrdLutpA%40mail.gmail.com
>>  
>> 
>> .
>>
>
>
> -- 
>
> *Michael T. jonesmichae...@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/a5227da6-c1ee-4754-95c4-c6bb1dd2d40f%40googlegroups.com.


[go-nuts] Re: undefined (type *math/rand.Rand has no field or method randIntn)

2020-02-25 Thread Jake Montgomery

On Tuesday, February 25, 2020 at 1:42:31 PM UTC-5, Anjana Prabhakar wrote:
>
> I get the error as r1.randIntn undefined (type *math/rand.Rand has no 
> field or method randIntn). Please help.
>

The message is  pretty clear. The first step I would take with a message 
like that is to look at the documentation for the type that the compiler 
has so kindly provided. If you go to the documentation for the rand package 
, you will see that the Rand 
struct has no method 'randIntn', just as the message says. The next step 
would be to read about the methods that are available for rand.Rand, and 
see if any of them fit your needs. 

(The fact that randIntn starts with a lower case letter is a big hint that 
there could be no such public method.)

Good Luck

-- 
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/31c75a31-e0d9-444e-acf9-487273f55594%40googlegroups.com.


Re: [go-nuts] undefined (type *math/rand.Rand has no field or method randIntn)

2020-02-25 Thread burak serdar
On Tue, Feb 25, 2020 at 11:42 AM Anjana Prabhakar
 wrote:
>
> Hi All,
>
> I am trying to generate a random integer using the below code snippet:
> package ABC
> import (
> *
> "math/rand"
> )
> func execBlock(
> logger log.Logger,) {
> var validTxs, invalidTxs, unchkdTxs = 0, 0, 0
>
> txIndex := 0
> proxyCb := func(req *xxx, res *yyy) {
> if r, ok := res.Value.(*); ok {
> txRes := r.DeliverTx
> // code for random integer begin
>   s1 := rand.NewSource(time.Now().UnixNano())
> r1 := rand.New(s1)
> toCheck := r1.randIntn(100) // getting error for this line
> if toCheck <= 65{
> ***
> }else {
> *
> }// end
> }
> }
> }
>
> I get the error as r1.randIntn undefined (type *math/rand.Rand has no field 
> or method randIntn). Please help.

It doesn't have randIntn, it has Intn, so use r1.Intn(100)

>
> Thanks,
> Anjana
>
> --
> 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/5f0fc1e1-3554-4d2d-b7e4-0fbc196e1b53%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/CAMV2Rqq04S4DFNLi6iX81%2BQDPsm%2BzqGjaNGcRXvOsA%3D2NDoNoQ%40mail.gmail.com.


[go-nuts] undefined (type *math/rand.Rand has no field or method randIntn)

2020-02-25 Thread Anjana Prabhakar
Hi All,

I am trying to generate a random integer using the below code snippet:
package ABC
import (
*
"math/rand"
)
func execBlock(
logger log.Logger,) {
var validTxs, invalidTxs, unchkdTxs = 0, 0, 0

txIndex := 0
proxyCb := func(req *xxx, res *yyy) {
if r, ok := res.Value.(*); ok {
txRes := r.DeliverTx
// code for random integer begin
  s1 := rand.NewSource(time.Now().UnixNano())
r1 := rand.New(s1)
toCheck := r1.randIntn(100) // getting error for this line
if toCheck <= 65{
***
}else {
*
}// end
}
}
}

I get the error as r1.randIntn undefined (type *math/rand.Rand has no field 
or method randIntn). Please help.

Thanks,
Anjana

-- 
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/5f0fc1e1-3554-4d2d-b7e4-0fbc196e1b53%40googlegroups.com.


Re: [go-nuts] Fuchsia Programming Language Policy

2020-02-25 Thread Michael Jones
Actually, you should read the whole note -- it's fun. Half of the languages
are bad because of memory leaks, the other half are bad because of having
GC; half are bad because of difficult asynchronism, the other half are bad
because of having a runtime. etc.

It reads like an imperiously-worded tautology about
safety/power/convenience coming at a cost.

On Tue, Feb 25, 2020 at 9:51 AM Mohamed Yousif  wrote:

> It seems they are betting high on Dart/flutter and their front end is
> already written with flutter. The assessment seems to be pretty much the
> same as for Dart.
>
> Dart won with the ui side, while go was competing with C.
>
> On Tue, 25 Feb 2020 at 7:22 PM, Jon Conradt  wrote:
>
>> The Fuchsia Programming Language Policy
>> 
>>  gives
>> some insight into the experience the Fuchsia team has had with Go, and it
>> doesn't sound good.
>>
>> "The Fuchsia Platform Source Tree has had negative implementation
>> experience using Go. The system components the Fuchsia project has built in
>> Go have used more memory and kernel resources than their counterparts (or
>> replacements) the Fuchsia project has built using C++ or Rust."
>>
>>
>> The Fuchsia Platform Source tree is defined as "The *Fuchsia Platform
>> Source Tree* is the source code hosted on fuchsia.googlesource.com."
>>
>> Their conclusion, and each language has some issues is pretty severe.
>>
>>- Go is not approved, with the following exceptions:
>>   - *netstack*. Migrating netstack to another language would require
>>   a significant investment. In the fullness of time, we should migrate
>>   netstack to an approved language.
>>- All other uses of Go in Fuchsia for production software on the
>>target device must be migrated to an approved language.
>>
>>  That's a shame. I was hoping that Fuchsia would provide a way for Go to
>> have a nice GUI.
>>
>> Two of the issues listed as cons include the toolchain producing 'large
>> binaries' and the related issue of their being a 'substantial runtime.' It
>> seems to me that both of these issues can be addressed through some of the
>> techniques used to build tiny Docker images from Go, but I suspect they
>> would like to have a much simpler route, e.g. a go build flag.
>>
>> Jon
>>
>> --
>> 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/7778a387-f1f5-4ed0-8453-5b811bac4a6d%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/CAHrL7wHqJnDnEVe4%3D--%3DcSW9oA-eYxcbKagESdZHgSkrdLutpA%40mail.gmail.com
> 
> .
>


-- 

*Michael T. jonesmichael.jo...@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/CALoEmQx0mMnuKQHOrp9ptxM1iN5y9%2B3rXYDZ4TaOYK%3DfXmq4Sg%40mail.gmail.com.


Re: [go-nuts] Fuchsia Programming Language Policy

2020-02-25 Thread Mohamed Yousif
It seems they are betting high on Dart/flutter and their front end is
already written with flutter. The assessment seems to be pretty much the
same as for Dart.

Dart won with the ui side, while go was competing with C.

On Tue, 25 Feb 2020 at 7:22 PM, Jon Conradt  wrote:

> The Fuchsia Programming Language Policy
> 
>  gives
> some insight into the experience the Fuchsia team has had with Go, and it
> doesn't sound good.
>
> "The Fuchsia Platform Source Tree has had negative implementation
> experience using Go. The system components the Fuchsia project has built in
> Go have used more memory and kernel resources than their counterparts (or
> replacements) the Fuchsia project has built using C++ or Rust."
>
>
> The Fuchsia Platform Source tree is defined as "The *Fuchsia Platform
> Source Tree* is the source code hosted on fuchsia.googlesource.com."
>
> Their conclusion, and each language has some issues is pretty severe.
>
>- Go is not approved, with the following exceptions:
>   - *netstack*. Migrating netstack to another language would require
>   a significant investment. In the fullness of time, we should migrate
>   netstack to an approved language.
>- All other uses of Go in Fuchsia for production software on the
>target device must be migrated to an approved language.
>
>  That's a shame. I was hoping that Fuchsia would provide a way for Go to
> have a nice GUI.
>
> Two of the issues listed as cons include the toolchain producing 'large
> binaries' and the related issue of their being a 'substantial runtime.' It
> seems to me that both of these issues can be addressed through some of the
> techniques used to build tiny Docker images from Go, but I suspect they
> would like to have a much simpler route, e.g. a go build flag.
>
> Jon
>
> --
> 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/7778a387-f1f5-4ed0-8453-5b811bac4a6d%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/CAHrL7wHqJnDnEVe4%3D--%3DcSW9oA-eYxcbKagESdZHgSkrdLutpA%40mail.gmail.com.


[go-nuts] Fuchsia Programming Language Policy

2020-02-25 Thread Jon Conradt
The Fuchsia Programming Language Policy 

 gives 
some insight into the experience the Fuchsia team has had with Go, and it 
doesn't sound good.

"The Fuchsia Platform Source Tree has had negative implementation 
experience using Go. The system components the Fuchsia project has built in 
Go have used more memory and kernel resources than their counterparts (or 
replacements) the Fuchsia project has built using C++ or Rust."


The Fuchsia Platform Source tree is defined as "The *Fuchsia Platform 
Source Tree* is the source code hosted on fuchsia.googlesource.com."

Their conclusion, and each language has some issues is pretty severe.

   - Go is not approved, with the following exceptions:
  - *netstack*. Migrating netstack to another language would require a 
  significant investment. In the fullness of time, we should migrate 
netstack 
  to an approved language.
   - All other uses of Go in Fuchsia for production software on the target 
   device must be migrated to an approved language.

 That's a shame. I was hoping that Fuchsia would provide a way for Go to 
have a nice GUI.

Two of the issues listed as cons include the toolchain producing 'large 
binaries' and the related issue of their being a 'substantial runtime.' It 
seems to me that both of these issues can be addressed through some of the 
techniques used to build tiny Docker images from Go, but I suspect they 
would like to have a much simpler route, e.g. a go build flag.

Jon

-- 
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/7778a387-f1f5-4ed0-8453-5b811bac4a6d%40googlegroups.com.


Re: [go-nuts] Understind how to apply timeout using gouritine

2020-02-25 Thread Jake Montgomery

>
> Expected behaviour is  to end  anonyimous func when  3s timeout is reached.
>

So what is the problem? The whole thing *does *exit after 3 seconds. Of 
course, your main() is a loop, so it starts again. 

2009/11/10 23:00:00 -Start
2009/11/10 23:00:03 Canceling doWork goroutine reach 3s...
2009/11/10 23:00:03 doWork exited.
2009/11/10 23:00:03 Done.
2009/11/10 23:00:03 -End


What exactly did you expect to see other than that?

On Monday, February 24, 2020 at 6:45:26 PM UTC-5, Juan Mamani wrote:
>
> Sorry again.   Well, I followed your advice. Here is the link 
> https://play.golang.org/p/7DigEVsKbdx
> How can I cancel goToSleep() when timeout is reached?
>
>
> El lunes, 24 de febrero de 2020, 14:16:32 (UTC-3), Jake Montgomery 
> escribió:
>>
>> Your code will still not compile. In this group, it is often helpful to 
>> include a link to your code in the playground (https://play.golang.org/) 
>> using the "Share" button. That is in addition to, or instead of, posting 
>> your code in the message. This will allow others to easily run your code, 
>> but also will allow you to make sure it compiles. 
>>
>> On Monday, February 24, 2020 at 10:01:01 AM UTC-5, Juan Mamani wrote:
>>>
>>> Sorry}, here is the right code:  ( just was the effect to b working til 
>>> At 5:20am  sleepy and lost)
>>>
>>> Expected behaviour is  to end  anonyimous func when  3s timeout is 
>>> reached.
>>>
>>> //
>>> package main
>>>
>>> import(
>>> //"fmt"
>>> "time"
>>> "math/rand"
>>> "log"
>>> )
>>>
>>> func main(){
>>>
>>>  for{
>>>log.Println("-Start")
>>>Task()
>>>log.Println("-End")
>>>
>>>   }
>>>
>>> }
>>>
>>>
>>> // Trying to adapt from Concurrency in Go by Katherine Cox-Buday
>>> func Task(){
>>>
>>> doWork := func(  done <-chan interface{}, strings <-chan string, ) 
>>> <-chan interface{} { //1
>>> terminated := make(chan interface{})
>>> go func() {
>>> defer log.Println("doWork exited.")
>>> defer close(terminated)
>>> for {
>>> goToSleep()
>>> select {
>>>  //case s := <-strings:
>>>  // case s := ran():
>>> // Do something interesting
>>> //fmt.Println(s)
>>> case <-done: //2
>>> return
>>> }
>>> }
>>> }()
>>> return terminated
>>> }
>>>
>>> done := make(chan interface{})
>>> terminated := doWork(done, nil)
>>>
>>> go func() { //3
>>> // Cancel the operation after 3 second.
>>> time.Sleep(3 * time.Second)
>>> log.Println("Canceling doWork goroutine reach 3s...")
>>> close(done)
>>> }()
>>>
>>> <-terminated //4
>>> log.Println("Done.")
>>> }
>>>
>>> done := make(chan interface{})
>>> terminated := doWork(done, nil)
>>>
>>> go func() { //3
>>> // Cancel the operation after 3 second.
>>> time.Sleep(3 * time.Second)
>>> log.Println("Canceling doWork goroutine reach 3s...")
>>> close(done)
>>> }()
>>>
>>> <-terminated //4
>>> log.Println("Done.")
>>> }
>>>
>>>
>>>
>>> func goToSleep(){
>>> 
>>> 
>>> 
>>>  
>>> rand.Seed(time.Now().UnixNano())
>>> n := rand.Intn(12) // n will be between 0 and 10
>>> log.Println("Sleeping ",n,"seconds..")
>>> time.Sleep(time.Duration(n)*time.Second)
>>> log.Println("Done sleeping!")
>>> }
>>>
>>> //
>>>
>>>
>>>
>>> El lunes, 24 de febrero de 2020, 6:09:09 (UTC-3), Lutz Horn escribió:

 > I've tried to adapt from from "Concurrency in Go by Katherine 
 Cox-Buday" to 
 > understand how to apply timeout. But I don't get it. 

 What are you trying to do? What is the expected behaviour, what happens 
 instead? 

 BTW, this code does not compile, there are same unbalanced curly 
 brackets. 

 Lutz 

>>>

-- 
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/c7c67bfc-ed0a-49bd-b87b-cef6521f996a%40googlegroups.com.


[go-nuts] Converting *byte to unsafe.Pointer and back to *byte

2020-02-25 Thread dmitry.neverov via golang-nuts
What is the meaning of the conversion

var b []byte
var p *byte = (*byte)(unsafe.Pointer(*b[0]))

It is used for example in 
https://github.com/golang/net/blob/master/internal/socket/iovec_64bit.go.

How it is different from

var b []byte
var p *byte = [0]

Thank 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/1f0d958c-5af8-4e06-8aad-99e6166354e0%40googlegroups.com.


Re: [go-nuts] Understind how to apply timeout using gouritine

2020-02-25 Thread Michel Levieux
Edit: I said "communicate with its caller" but in practice it might as well
be another goroutine or the caller of the caller, either way the construct
and the logic standing behind it are exactly the same :)

Le mar. 25 févr. 2020 à 09:42, Michel Levieux  a
écrit :

> Hi Juan,
>
> You cannot terminate a function execution from its caller if you did not
> pass it an argument (most likely a channel) which it can use to communicate
> with its caller, and terminate itself when the timeout is reached.
> The simplest example I can think of is the following:
> https://play.golang.org/p/KVQ7uhiWr7H, though I'm not quite sure this is
> your question, since it looks like you've already experimented with this
> construct.
>
> You can trick with signals and other constructs but channels are designed
> for that kind of need, so I suppose this is the best way to go. If you want
> something that wraps this behaviour because you need the timeout to follow
> the logic of your program, maybe package https://golang.org/pkg/context/
> can help you.
>
> Hope this was useful!
>
> Le mar. 25 févr. 2020 à 00:45, Juan Mamani 
> a écrit :
>
>> Sorry again.   Well, I followed your advice. Here is the link
>> https://play.golang.org/p/7DigEVsKbdx
>> How can I cancel goToSleep() when timeout is reached?
>>
>>
>> El lunes, 24 de febrero de 2020, 14:16:32 (UTC-3), Jake Montgomery
>> escribió:
>>>
>>> Your code will still not compile. In this group, it is often helpful to
>>> include a link to your code in the playground (https://play.golang.org/)
>>> using the "Share" button. That is in addition to, or instead of, posting
>>> your code in the message. This will allow others to easily run your code,
>>> but also will allow you to make sure it compiles.
>>>
>>> On Monday, February 24, 2020 at 10:01:01 AM UTC-5, Juan Mamani wrote:

 Sorry}, here is the right code:  ( just was the effect to b working til
 At 5:20am  sleepy and lost)

 Expected behaviour is  to end  anonyimous func when  3s timeout is
 reached.

 //
 package main

 import(
 //"fmt"
 "time"
 "math/rand"
 "log"
 )

 func main(){

  for{
log.Println("-Start")
Task()
log.Println("-End")

   }

 }


 // Trying to adapt from Concurrency in Go by Katherine Cox-Buday
 func Task(){

 doWork := func(  done <-chan interface{}, strings <-chan string, )
 <-chan interface{} { //1
 terminated := make(chan interface{})
 go func() {
 defer log.Println("doWork exited.")
 defer close(terminated)
 for {
 goToSleep()
 select {
  //case s := <-strings:
  // case s := ran():
 // Do something interesting
 //fmt.Println(s)
 case <-done: //2
 return
 }
 }
 }()
 return terminated
 }

 done := make(chan interface{})
 terminated := doWork(done, nil)

 go func() { //3
 // Cancel the operation after 3 second.
 time.Sleep(3 * time.Second)
 log.Println("Canceling doWork goroutine reach 3s...")
 close(done)
 }()

 <-terminated //4
 log.Println("Done.")
 }

 done := make(chan interface{})
 terminated := doWork(done, nil)

 go func() { //3
 // Cancel the operation after 3 second.
 time.Sleep(3 * time.Second)
 log.Println("Canceling doWork goroutine reach 3s...")
 close(done)
 }()

 <-terminated //4
 log.Println("Done.")
 }



 func goToSleep(){




 rand.Seed(time.Now().UnixNano())
 n := rand.Intn(12) // n will be between 0 and 10
 log.Println("Sleeping ",n,"seconds..")
 time.Sleep(time.Duration(n)*time.Second)
 log.Println("Done sleeping!")
 }

 //



 El lunes, 24 de febrero de 2020, 6:09:09 (UTC-3), Lutz Horn escribió:
>
> > I've tried to adapt from from "Concurrency in Go by Katherine
> Cox-Buday" to
> > understand how to apply timeout. But I don't get it.
>
> What are you trying to do? What is the expected behaviour, what
> happens instead?
>
> BTW, this code does not compile, there are same unbalanced curly
> brackets.
>
> Lutz
>
 --
>> 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/b0828575-fddf-4024-bec0-8faf5b9858a4%40googlegroups.com

Re: [go-nuts] Understind how to apply timeout using gouritine

2020-02-25 Thread Michel Levieux
Hi Juan,

You cannot terminate a function execution from its caller if you did not
pass it an argument (most likely a channel) which it can use to communicate
with its caller, and terminate itself when the timeout is reached.
The simplest example I can think of is the following:
https://play.golang.org/p/KVQ7uhiWr7H, though I'm not quite sure this is
your question, since it looks like you've already experimented with this
construct.

You can trick with signals and other constructs but channels are designed
for that kind of need, so I suppose this is the best way to go. If you want
something that wraps this behaviour because you need the timeout to follow
the logic of your program, maybe package https://golang.org/pkg/context/
can help you.

Hope this was useful!

Le mar. 25 févr. 2020 à 00:45, Juan Mamani  a
écrit :

> Sorry again.   Well, I followed your advice. Here is the link
> https://play.golang.org/p/7DigEVsKbdx
> How can I cancel goToSleep() when timeout is reached?
>
>
> El lunes, 24 de febrero de 2020, 14:16:32 (UTC-3), Jake Montgomery
> escribió:
>>
>> Your code will still not compile. In this group, it is often helpful to
>> include a link to your code in the playground (https://play.golang.org/)
>> using the "Share" button. That is in addition to, or instead of, posting
>> your code in the message. This will allow others to easily run your code,
>> but also will allow you to make sure it compiles.
>>
>> On Monday, February 24, 2020 at 10:01:01 AM UTC-5, Juan Mamani wrote:
>>>
>>> Sorry}, here is the right code:  ( just was the effect to b working til
>>> At 5:20am  sleepy and lost)
>>>
>>> Expected behaviour is  to end  anonyimous func when  3s timeout is
>>> reached.
>>>
>>> //
>>> package main
>>>
>>> import(
>>> //"fmt"
>>> "time"
>>> "math/rand"
>>> "log"
>>> )
>>>
>>> func main(){
>>>
>>>  for{
>>>log.Println("-Start")
>>>Task()
>>>log.Println("-End")
>>>
>>>   }
>>>
>>> }
>>>
>>>
>>> // Trying to adapt from Concurrency in Go by Katherine Cox-Buday
>>> func Task(){
>>>
>>> doWork := func(  done <-chan interface{}, strings <-chan string, )
>>> <-chan interface{} { //1
>>> terminated := make(chan interface{})
>>> go func() {
>>> defer log.Println("doWork exited.")
>>> defer close(terminated)
>>> for {
>>> goToSleep()
>>> select {
>>>  //case s := <-strings:
>>>  // case s := ran():
>>> // Do something interesting
>>> //fmt.Println(s)
>>> case <-done: //2
>>> return
>>> }
>>> }
>>> }()
>>> return terminated
>>> }
>>>
>>> done := make(chan interface{})
>>> terminated := doWork(done, nil)
>>>
>>> go func() { //3
>>> // Cancel the operation after 3 second.
>>> time.Sleep(3 * time.Second)
>>> log.Println("Canceling doWork goroutine reach 3s...")
>>> close(done)
>>> }()
>>>
>>> <-terminated //4
>>> log.Println("Done.")
>>> }
>>>
>>> done := make(chan interface{})
>>> terminated := doWork(done, nil)
>>>
>>> go func() { //3
>>> // Cancel the operation after 3 second.
>>> time.Sleep(3 * time.Second)
>>> log.Println("Canceling doWork goroutine reach 3s...")
>>> close(done)
>>> }()
>>>
>>> <-terminated //4
>>> log.Println("Done.")
>>> }
>>>
>>>
>>>
>>> func goToSleep(){
>>>
>>>
>>>
>>>
>>> rand.Seed(time.Now().UnixNano())
>>> n := rand.Intn(12) // n will be between 0 and 10
>>> log.Println("Sleeping ",n,"seconds..")
>>> time.Sleep(time.Duration(n)*time.Second)
>>> log.Println("Done sleeping!")
>>> }
>>>
>>> //
>>>
>>>
>>>
>>> El lunes, 24 de febrero de 2020, 6:09:09 (UTC-3), Lutz Horn escribió:

 > I've tried to adapt from from "Concurrency in Go by Katherine
 Cox-Buday" to
 > understand how to apply timeout. But I don't get it.

 What are you trying to do? What is the expected behaviour, what happens
 instead?

 BTW, this code does not compile, there are same unbalanced curly
 brackets.

 Lutz

>>> --
> 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/b0828575-fddf-4024-bec0-8faf5b9858a4%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