Re: [go-nuts] Help with Go channels and select talk

2019-12-07 Thread Robert Engels
I’m sorry, but it’s very hard to understand when you start with solutions. I think maybe clearly restating the problem will allow more people to offer up ideas. To be honest at this point I’m not really certain what you’re trying to demonstrate or why. > On Dec 8, 2019, at 12:44 AM, Egon

Re: [go-nuts] Help with Go channels and select talk

2019-12-07 Thread Egon Kocjan
I meant lock-free as in "without explicit locks". The original challenge still stands if someone has a better solution than me: "The deadlocks in 2_1.go and 2_2.go are caused by the simplistic and wrong implementation of bidi-comm, which is what I'll be illustrating. I have three working

Re: [go-nuts] Help with Go channels and select talk

2019-12-07 Thread Robert Engels
I understand what you are saying but I’ll still suggest that your premise/design is not correct. There are plenty of useful lock free structures in Go (see github.com/robaho/go-concurrency-test) but that is not what you are attempting here... you are using async processing - these are

Re: [go-nuts] Help with Go channels and select talk

2019-12-07 Thread Egon Kocjan
I'll cite myself: "I'm preparing a short talk about Go channels and select. More specifically, I want to show what not to do." and "it would be tempting to just combine two goroutines into one and handle caching in a single loop without using locks (I see developers avoid atomics and locks if

Re: [go-nuts] Re: Where is the middle of Brazil?

2019-12-07 Thread Marcin Romaszewicz
As a bonus challenge, try to compute the population center of Brazil :) One way of finding the center is minimizing the integral of all distances to a point, but for population, these points now have weight. Like Michael above, I spent years working on Google Earth, and the code running in the

Re: [go-nuts] Re: getting a function docs when you have a *packages.Package

2019-12-07 Thread Dan Kortschak
I completely missed the .Doc field in the ast.FuncDecl type. That's perfect. Thanks. On Sat, 2019-12-07 at 03:47 -0800, Charith Ellawala wrote: > I am searching for a good way of doing this myself. An approach that > seems > to work reasonably well is to just iterate through the AST files and >

[go-nuts] Re: Way to handle errors in goroutine. Is this safe?

2019-12-07 Thread Jake Montgomery
As Ian pointed out, the code you provided has a race condition. Using timers to try to avoid a race like you do here may work *most *of the time, but it is not rigorously correct. When dealing with concurrency is is critical to always be 100% rigorusly "correct". Otherwise you will eventually

Re: [go-nuts] rpc.debugLog unexported

2019-12-07 Thread Ian Lance Taylor
On Sat, Dec 7, 2019 at 9:12 AM wrote: > > How can I turn on debugging in net/rpc/server.go? > > There is a promising variable called `debugLog` in there. How should I > toggle it? I don't know how much it will help, but the way to toggle it is to literally edit net/rpc/debug.go to set debugLog

Re: [go-nuts] Way to handle errors in goroutine. Is this safe?

2019-12-07 Thread Ian Lance Taylor
On Sat, Dec 7, 2019 at 9:12 AM kr c wrote: > > https://play.golang.org/p/mqpT8XBbeiN > > Hi, Everyone! I'm newbie in go. Help needed. > As far as I learned, gorutines should pass "value" through channels. > There's more safe way to handle this kind of stuffs with using waitgroup, > context,

Re: [go-nuts] Re: Where is the middle of Brazil?

2019-12-07 Thread JuciÊ Andrade
Yes, I understand it is impossible to chose the "correct way" of determining the center. This week I learnt there are at least a handful of places claiming to be the "center" of Brazil, with monuments and whatnot. The search for a solution is an interesting endeavor per se. Programming is

Re: [go-nuts] Re: Where is the middle of Brazil?

2019-12-07 Thread Michael Jones
...now *this* is something that I know a great deal about (resulting in label placement in Google Maps and Google Earth, discussions with colleagues in USGS, the US Census Bureau, DoD, the United Nations GGIM experts group, UK Ordnance Survey, Survey of India, etc.) Indeed most of the issues

[go-nuts] Re: getting a function docs when you have a *packages.Package

2019-12-07 Thread Charith Ellawala
I am searching for a good way of doing this myself. An approach that seems to work reasonably well is to just iterate through the AST files and extract the function declarations: cfg := { Mode: packages.NeedName | packages.NeedTypes | packages.NeedSyntax | packages.NeedFiles, Dir:

[go-nuts] Way to handle errors in goroutine. Is this safe?

2019-12-07 Thread kr c
package main import ( "errors" "log" "time" ) func main() { err := f() if err != nil { log.Fatal(err) } } func f() (err error) { var rerr error defer func() { if rerr != nil {

[go-nuts] rpc.debugLog unexported

2019-12-07 Thread dick . r . chiang
How can I turn on debugging in net/rpc/server.go? There is a promising variable called `debugLog` in there. How should I toggle it? -- 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

Re: [go-nuts] Re: Where is the middle of Brazil?

2019-12-07 Thread andrey mirtchovski
this is quickly becoming off-topic. however, from https://en.wikipedia.org/wiki/Geographical_centre: "As noted in a USGS document "There is no generally accepted definition of geographic center, and no completely satisfactory method for determining it."[1] In general, there is room for debate

Re: [go-nuts] Re: Where is the middle of Brazil?

2019-12-07 Thread JuciÊ Andrade
If one wants to improve precision she may use a bigger map. The resulting position would be the same, only more accurate. -- 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

Re: [go-nuts] Re: Where is the middle of Brazil?

2019-12-07 Thread JuciÊ Andrade
Hi, Jan. As you can imagine, there are several ways to define "middle". So, to get rid of the ambiguity I picked this one: "the position would divide Brazil so that half of our country area would be to the north and half to the south, while half would be to the west and half to the east." On

Re: [go-nuts] Multiple processes in parallel for cgo service

2019-12-07 Thread Jake Montgomery
Nitish, I don't think you really explained the problem you are having. There is nothing in go that prevents you from running multiple instances of an executable, hence creating multiple processes running the same program. You can simply open two console windows and start the same long

Re: [go-nuts] Help with Go channels and select talk

2019-12-07 Thread Robert Engels
Probably not. Go is designed for 1:1 and there is no reason to do it differently. You could probably try to write an async event driven layer (which it looks like you’ve tried) but why??? It’s like saying I’d really like my plane to float - you can do that -but most likely you want a boat

Re: [go-nuts] Multiple processes in parallel for cgo service

2019-12-07 Thread Nitish Saboo
Hi Brian, I understand by running the service as containers is one route through which we can achieve this. My query is if I want to avoid that route , is there a way to achieve this using Go code to define multiple instance and run them independently? Thanks, Nitish On Sat, Dec 7, 2019 at 1:52

Re: [go-nuts] Re: Where is the middle of Brazil?

2019-12-07 Thread Jan Mercl
On Sat, Dec 7, 2019 at 2:34 PM JuciÊ Andrade wrote: > I am pretty sure there are other ways to do it, but the method I devised is > simple and produces a good enough result. If somebody can put a hole in my > reasoning, feel free to do so. > > All the info I need are in a map, OK? So I

[go-nuts] Re: Where is the middle of Brazil?

2019-12-07 Thread JuciÊ Andrade
I am pretty sure there are other ways to do it, but the method I devised is simple and produces a good enough result. If somebody can put a hole in my reasoning, feel free to do so. All the info I need are in a map, OK? So I downloaded a map from the Internet. I choose a map that shows only

[go-nuts] Re: Where is the middle of Brazil?

2019-12-07 Thread JuciÊ Andrade
OK, people. It has been nearly a week since I left the programming challenge here, so let me show my approach. First, let me tell you guys I sent the aforementioned challenge to a few programming groups and it went like this: . some very knowledgeable people in this group tried to find a

[go-nuts] [ANN] chasquid (SMTP server) v1.2

2019-12-07 Thread Alberto Bertogli
Hi! chasquid v1.2 has been released. chasquid is an SMTP (email) server with a focus on simplicity, security, and ease of operation. It's written in Go, and is open source under the Apache license 2.0. See https://blitiri.com.ar/p/chasquid/ for more information. This release fixes a

Re: [go-nuts] Help with Go channels and select talk

2019-12-07 Thread Egon Kocjan
I'll try to clarify as best as I can, thanks again to anyone looking at this. The simple server implementation of "output <- input+1" is here and it is not "under our control" - it's what we have to work with: https://github.com/egonk/chandemo/blob/master/server.go The test runner or client