Re: [go-nuts] How do you implement and use Context.Done?

2017-02-19 Thread Sina Siadat
Done function returns a channel which is closed when our context is done, i.e., it is either timed out, its deadline is exceeded, or explicitly canceled. This channel closing is a pattern used for broadcasting a signal to multiple goroutines that are receiving from it. Let's say we have 2

[go-nuts] Go Concurrency Patterns: Pipelines

2017-02-19 Thread maroloccio
See: https://blog.golang.org/pipelines (in which Go computes MD5 sums of files under a dir) A machine K has: - M total memory in bytes - C number of (logical) CPUs and a workload W consisting in MD5'ing some files under directory d/: - N total number of files - m bytes per file (all files are

[go-nuts] Argument types of: anonymous function literals used as arguments of other function calls

2017-02-19 Thread Marco Ippolito
Consider: func HandleFunc(pattern string, handler func(ResponseWriter, *Request)) and: http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) { ... Could this be made to work? http.HandleFunc("/", func(w, r) { ... in an "auto" kind of way? -- You received this

Re: [go-nuts] Parse JSON in Template

2017-02-19 Thread Rejoy Nair
Yes, there could be ways to do it. I could have used Javascript to access the JSON data values. But couldn't get that to work either. So the easier thing for me to do was to unmarshal the string again into a map([string]interface{}) type which is what I finally did to get the code to work. Thanks

Re: [go-nuts] Question about net/http package implementation

2017-02-19 Thread Dan Kortschak
On Sat, 2017-02-18 at 23:15 +, Matt Harden wrote: > They didn't say ; they said r2 := *r. Also read the example. > They > returned instead of r2. The code is equivalent to but shorter > than the > original. After I read the example I realised that. However the text shows up on a text-only

[go-nuts] Re: Re[2]: Golang server background notofication process

2017-02-19 Thread Diego Medina
Hi, Instead of starting them from an http handler, I would store in the database the locations and their users. Then, from main() I would start just one go routine that will check the db for any pending location that needs to be fetched, if found, then go do work, sleep for x seconds, then check

Re: [go-nuts] Re: Arguments for writing fast, high-load servers in Go instead of Scala?

2017-02-19 Thread Diego Medina
Looks like you have a pretty good list already, depending on how much they love Scala, they may/may not invalidate some of your points but you know them better. On Sun, Feb 19, 2017 at 2:37 AM, Will Faught wrote: > Thanks to the two replies so far! Very helpful. > > Here

Re: [go-nuts] How do you implement and use Context.Done?

2017-02-19 Thread Matt Harden
Done does not need to be called unless you want to detect when the context is either canceled or times out. It doesn't have any effect on the context itself. On Sun, Feb 19, 2017 at 2:57 PM wrote: > Thanks, I see you build it up with decorators on a standard prototype. > For

Re: [go-nuts] How do you implement and use Context.Done?

2017-02-19 Thread so . query
Thanks, I see you build it up with decorators on a standard prototype. For example: https://play.golang.org/p/PJy5lE9QqF So context.Done is a convenience function for those that require it? Otherwise a context will expire after it leaves scope, so Done does not need to be called? On

Re: [go-nuts] Re: int16 and float64 Multiplication

2017-02-19 Thread 'simon place' via golang-nuts
if using fixed precision then don't use floats, just use int's with a fixed multiplier. -- 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

Re: [go-nuts] is this race condition normal?

2017-02-19 Thread Jesper Louis Andersen
On Sun, Feb 19, 2017 at 9:41 AM Marwan abdel moneim wrote: > i wanted to do it without a Mutex > but there still something not clear to me, but i don't know what it is > and i don't understand what "trigger" synchronization means > > Modern CPUs achieve much of their speed by

[go-nuts] [Gobot v1.2] - I2C PiGlow [SN3218] driver help

2017-02-19 Thread Owen Waller
Hi Everyone, With the release of GoBot 1.2 I thought I would try and put together a "metal bot" for the PiGlow on a Raspberry Pi 1.  The PiGlow is based around a SN3218 IC that drives the 18 leds on the board. The SN3218 communication with the Pi is via 12c. GoBot 1.2 rewrote the i2c subsystem,

Re: [go-nuts] correct/working 9p2000 library in Go?

2017-02-19 Thread Dave MacFarlane
On Sun, Feb 19, 2017 at 5:39 PM, Jason E. Aten wrote: > I'd like to play with the 9p protocol (plan9's "everything is a filesystem" > IPC protocol; I guess the updated 9p2000 version is the one everyone > actually uses) ... > > ...but the implementations I can find in Go seem

Re: [go-nuts] 9fans.net/go

2017-02-19 Thread Skip Tavakkolian
It's not abandoned; it's resting :) On Sun, Feb 19, 2017 at 10:08 AM Dave MacFarlane wrote: > Sure, but I'm not the one using plan9/client: plumb.Open is. So in > order to do it and keep supporting p9p, I still need to fork > 9fans.net/go and vendor my changes to the plumb

Re: [go-nuts] 9fans.net/go

2017-02-19 Thread Dave MacFarlane
Sure, but I'm not the one using plan9/client: plumb.Open is. So in order to do it and keep supporting p9p, I still need to fork 9fans.net/go and vendor my changes to the plumb package, which brings me back to where I started: needing to maintain my own fork of a seemingly abandoned package. (I

[go-nuts] correct/working 9p2000 library in Go?

2017-02-19 Thread Jason E. Aten
I'd like to play with the 9p protocol (plan9's "everything is a filesystem" IPC protocol; I guess the updated 9p2000 version is the one everyone actually uses) ... ...but the implementations I can find in Go seem half-done/incomplete/unmaintained. http://9p.cat-v.org/implementations +

Re: [go-nuts] is this race condition normal?

2017-02-19 Thread Matt Harden
Doing it in C would also require a mutex or other synchronization primitive. On Sun, Feb 19, 2017 at 7:11 AM Marwan abdel moneim wrote: > i didn't want to use Mutex because i wanted to learn the topic from the > beginning, and see how it could be done without channels or

Re: [go-nuts] Parse JSON in Template

2017-02-19 Thread Hugh S. Myers
The devil sitting on my shoulder tempts me to say "Of course, there is" and walk away. That said, by now there must exist code to read JSON (YAML, Windows config files, etc.) from a string. It's just a matter of finding it. - https://gobyexample.com/json -

[go-nuts] Parse JSON in Template

2017-02-19 Thread Rejoy
I am retrieving a set of field values from the Database into an interface type object. One of the field values is a JSON string (say Order detail). I am retrieving it as a string as passing it on to a template and referencing it using {{.orderdetail}} this is the output I get on the client

[go-nuts] Re: Registering a Go app as a protocol handler under Mac OS X

2017-02-19 Thread tahapahr
On Thursday, July 7, 2016 at 12:50:02 AM UTC+3, chris...@gmail.com wrote: > > Hi, > > I'm trying to hook up a Go application to a URL protocol handler in Mac OS > X. I want a user to be able to click on a link such as myapp://foo/bar and > have that launch myapp and be able to access the full

[go-nuts] Re: GOBIN Question

2017-02-19 Thread bsb . hro
Hi, I tried to run an then to install (go install) a package (freetype.go). I got this error on Linux, but I found that this is not a main package ('go run' showed it). My $GOBIN is set, but 'go install' shows 'GOBIN not set'. Install only works with func main() in the source. May be, your

[go-nuts] Shiny gldriver Texture.Fill

2017-02-19 Thread Dmitry Kravchenko
When will Texture.Fill be implemented in Shiny gldriver? golang.org/x/exp/shiny/driver/gldriver/texture.go : func (t *textureImpl) Fill(dr image.Rectangle, src color.Color, op draw.Op) { t.w.glctxMu.Lock() defer t.w.glctxMu.Unlock() // TODO. } -- You received this message

Re: [go-nuts] Re: int16 and float64 Multiplication

2017-02-19 Thread Michael Jones
good. On Sat, Feb 18, 2017 at 11:08 PM, wrote: > After some testing I just decided to instead round the numbers to 2 > decimals instead. Thank you for the heads up though. > > On Sunday, February 19, 2017 at 5:42:15 PM UTC+11, Michael Jones wrote: >> >> This feels unlikely.

Re: [go-nuts] is this race condition normal?

2017-02-19 Thread jmontgomery
On Sunday, February 19, 2017 at 3:41:13 AM UTC-5, Marwan abdel moneim wrote: > > i wanted to do it without a Mutex > but there still something not clear to me, but i don't know what it is > and i don't understand what "trigger" synchronization means > > i will keep reading, and go back to it

Re: [go-nuts] Re: Struggling with working directory

2017-02-19 Thread Diego Medina
> > > > Did get it working (1.8) on windows though a side note on Docs for Fedora > that putting the path in $HOME/.profile does not work and for me anyway I > needed to put it in .bashrc > https://golang.org/doc/install?download=go1.8.linux-amd64.tar.gz > > Great to know you got it working! re

[go-nuts] Re: Go 1.8 is released

2017-02-19 Thread ojucie
I know a lot of work has been put into this release cycle. So, I just want to thank everyone involved. In my job we are already using 1.8 in production code with great results. In particular, the speed improvements are noticeable (10% in some process I did a benchmark). Congratulations. --

[go-nuts] Re[2]: Golang server background notofication process

2017-02-19 Thread egortictac3
Thanks for your answer! Am I right, when starting goroutine like this? (With infinite loop inside goroutine function) func (ctl *Controller) startWatchUserLocation(username, location string) {      for {            data, err := ctl.ScrapeRoomsWithLocation(username, location) <- scraping info

Re: [go-nuts] 9fans.net/go

2017-02-19 Thread Skip Tavakkolian
if want to run those utilities in Plan 9 you don't need to worry about speaking 9P with the underlying services -- i.e. no need for plan9/client package. the file hierarchies for plumber, acme, draw, etc. are mounted into the process' namespace. for example, acme's namespace is mounted on

Re: [go-nuts] is this race condition normal?

2017-02-19 Thread Marwan abdel moneim
i wanted to do it without a Mutex but there still something not clear to me, but i don't know what it is and i don't understand what "trigger" synchronization means i will keep reading, and go back to it later and see it i get it thanks for your help On Sunday, February 19, 2017 at 9:32:28 AM