Re: [go-nuts] Where is my memory in Linux?

2018-02-02 Thread ppcfan
We started this Go application by supervisor, so this Go app should be the subprocess of supervisor. Do you think it is the problem? On Saturday, February 3, 2018 at 3:18:02 AM UTC+8, Justin Israel wrote: > > > > On Sat, Feb 3, 2018, 2:21 AM Zhang Rui > wrote: > >> Hello

[go-nuts] Re: “Design Patterns: Elements of Reusable Object-Oriented Software” in Go

2018-02-02 Thread as
I would rank them mostly unused. There was a point someone made in the past how choosing between design patterns is the equivalent of choosing calling conventions for functions, I don't remember the source, but I agree with the comparison. Most of these are superseded by struct and interface

Re: [go-nuts] Where is my memory in Linux?

2018-02-02 Thread Zhang Rui
Thank you for your reply. No, this app doesn't use cgo. It's a pure Go application. Another go application on this VM used cgo. But it also should not launch the subprocesses. 在 2018年2月3日星期六 UTC+8上午3:18:02,Justin Israel写道: > > > > On Sat, Feb 3, 2018, 2:21 AM Zhang Rui >

Re: [go-nuts] Re: Relaxing rules on slice comparison: would it make sense?

2018-02-02 Thread 'Axel Wagner' via golang-nuts
On Fri, Feb 2, 2018 at 9:59 PM, wrote: > > Each path represented as a slice of coordinates could be easily encoded to > a string and compared that way. > Ah, I misunderstood "path". > > As far as resource expenses go, we'd need benchmarks to say much. I > understand

Re: [go-nuts] Re: Relaxing rules on slice comparison: would it make sense?

2018-02-02 Thread matthewjuran
> > Are you sure that's the only edge-case? Because this thread is kinda long > and there might even be things we are not thinking about. In the original discussion above I see one opinion toward comparing headers and four toward by element values (like strings). I didn't see any additional

Re: [go-nuts] “Design Patterns: Elements of Reusable Object-Oriented Software” in Go

2018-02-02 Thread matthewjuran
Here’s my proxy example with “func (a ProxyCar) Drive()” instead of DriveCar (I didn’t think this would work), and an F-150: https://play.golang.org/p/drDDkx_e0Mp This may fix the signature difference but I see that having an interface type like you suggested for car would allow other data and

Re: [go-nuts] “Design Patterns: Elements of Reusable Object-Oriented Software” in Go

2018-02-02 Thread Josh Humphries
I didn't get a chance to look at all of them, but your Proxy pattern example is incorrect. The idea of a proxy is that the proxy object exposes the same interface as the underlying object, so they are substitutable. In your example, Car is concrete (meaning that callers cannot substitute any

Re: [go-nuts] Where is my memory in Linux?

2018-02-02 Thread Justin Israel
On Sat, Feb 3, 2018, 2:21 AM Zhang Rui wrote: > Hello gophers, > > I have a VM on Linode.com. OS is Cent OS 6.8 and kernel > is 4.14.12-x86_64-linode92. It has 1 CPU core and 2G RAM. > A Go application is running on this VM. > Free memory on this VM is 490M (with buffer and

Re: [go-nuts] Rate controlling the Go http server

2018-02-02 Thread mrx
Thanks again, much appreciated! Patrik Iselind Den 2 feb. 2018 16:33 skrev "Henrik Johansson" : > Happy to help! > > The limit can be anything from the link above or something more advanced > that Jesper suggested. The skeleton could be as outlined above however. > > On

[go-nuts] Re: any discourse-like forum in Go?

2018-02-02 Thread Sebastien Binet
On Wed, Jan 31, 2018 at 5:28 PM, Sebastien Binet wrote: > hi there, > > I am looking for a discourse-like forum, in Go. Does anybody know of such > a thing? > > Interestingly, reading the https://blog.golang.org/hello-china post, I > stumbled upon: > > - https://gocn.io > >

[go-nuts] “Design Patterns: Elements of Reusable Object-Oriented Software” in Go

2018-02-02 Thread matthewjuran
I’m looking at patterns summarized on Wikipedia from “Design Patterns: Elements of Reusable Object-Oriented Software” and writing out a few as the equivalent in Go. Visitor: https://play.golang.org/p/A5tNzxMmetH Abstract Factory: https://play.golang.org/p/SWwuX49eysd Factory Method:

Re: [go-nuts] Why is the omitted expression in a swtich code block a typed bool "true"?

2018-02-02 Thread 'Axel Wagner' via golang-nuts
I did end up asking git, why this was done and it gave this answer , which links to this discussion . Hope that helps On Fri, Feb 2, 2018 at 5:18 PM, wrote:

Re: [go-nuts] Why is the omitted expression in a swtich code block a typed bool "true"?

2018-02-02 Thread digg
On Friday, February 2, 2018 at 10:45:58 AM UTC-5, Axel Wagner wrote: > > From the spec: > > >> If the switch expression evaluates to an untyped constant, it is first >> converted to its default type; if it is an untyped boolean value, it is >> first converted to type bool. The predeclared

Re: [go-nuts] Why is the omitted expression in a swtich code block a typed bool "true"?

2018-02-02 Thread digg
On Friday, February 2, 2018 at 10:37:24 AM UTC-5, di...@veryhaha.com wrote: > > > > On Friday, February 2, 2018 at 10:27:04 AM UTC-5, Ian Lance Taylor wrote: >> >> On Fri, Feb 2, 2018 at 7:10 AM, wrote: >> > >> > Why not make it untyped? >> > >> > package main >> > >>

Re: [go-nuts] Why is the omitted expression in a swtich code block a typed bool "true"?

2018-02-02 Thread digg
On Friday, February 2, 2018 at 10:37:24 AM UTC-5, di...@veryhaha.com wrote: > > > > On Friday, February 2, 2018 at 10:27:04 AM UTC-5, Ian Lance Taylor wrote: >> >> On Fri, Feb 2, 2018 at 7:10 AM, wrote: >> > >> > Why not make it untyped? >> > >> > package main >> > >>

Re: [go-nuts] Why is the omitted expression in a swtich code block a typed bool "true"?

2018-02-02 Thread digg
On Friday, February 2, 2018 at 10:27:04 AM UTC-5, Ian Lance Taylor wrote: > > On Fri, Feb 2, 2018 at 7:10 AM, > wrote: > > > > Why not make it untyped? > > > > package main > > > > type T bool > > > > func f() T {return T(false)} > > > > func main() { > >

Re: [go-nuts] Rate controlling the Go http server

2018-02-02 Thread Henrik Johansson
Happy to help! The limit can be anything from the link above or something more advanced that Jesper suggested. The skeleton could be as outlined above however. On Fri, Feb 2, 2018, 15:40 mrx wrote: > On Fri, Feb 2, 2018 at 1:28 PM, Henrik Johansson

Re: [go-nuts] Why is the omitted expression in a swtich code block a typed bool "true"?

2018-02-02 Thread Ian Lance Taylor
On Fri, Feb 2, 2018 at 7:10 AM, wrote: > > Why not make it untyped? > > package main > > type T bool > > func f() T {return T(false)} > > func main() { > switch { > case f(): // invalid case f() in switch (mismatched types T and bool) > } > } The current language

[go-nuts] Re: Why is the omitted expression in a swtich code block a typed bool "true"?

2018-02-02 Thread digg
Looks the non-omitted "true" is also a typed value of "bool" type. package main type T bool func f() T {return T(false)} func main() { switch true { case f(): // invalid case f() in switch (mismatched types T and bool) } } On Friday, February 2, 2018 at 10:11:31 AM UTC-5,

[go-nuts] Why is the omitted expression in a swtich code block a typed bool "true"?

2018-02-02 Thread digg
Why not make it untyped? package main type T bool func f() T {return T(false)} func main() { switch { case f(): // invalid case f() in switch (mismatched types T and bool) } } -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To

Re: [go-nuts] Does go programmers should handle syscall.EINTR all by themselves after go1.9 when writing disk files?

2018-02-02 Thread Ian Lance Taylor
On Fri, Feb 2, 2018 at 6:07 AM, rmfr wrote: > > Does go programmers should handle syscall.EINTR all by themselves after > go1.9 when writing disk files? > > I just noticed this commit >

Re: [go-nuts] Rate controlling the Go http server

2018-02-02 Thread mrx
On Fri, Feb 2, 2018 at 1:28 PM, Henrik Johansson wrote: > You can either use one of the existing other routers that have meddleware > support or you could wrap your handlers in another handler much like this: > > handle("/foo",wrapHandler(rateLimiter, realHandler)) > > func

[go-nuts] Does go programmers should handle syscall.EINTR all by themselves after go1.9 when writing disk files?

2018-02-02 Thread rmfr
Does go programmers should handle syscall.EINTR all by themselves after go1.9 when writing disk files? I just noticed this commit https://github.com/golang/go/commit/c05b06a12d005f50e4776095a60d6bd9c2c91fac#diff-b7452e0f27c15f140b5e86f88e2d43deL192 If the answer is 'yes', I wonder why deleted

[go-nuts] Development infrastructure research

2018-02-02 Thread yia
Hi, I'm working with a startup that wants to bring the first-class development infrastructure of companies like Google to engineers at companies of all sizes. This project will be an open source effort. We are looking for software architects, software engineers, and DevOps engineers who

[go-nuts] Understanding how to use the "go/*" APIs

2018-02-02 Thread Paul Brousseau
I am working on a program to consume Go source code and maintain a running state of that program as a user edits that source in an IDE. I have a working implementation that *loads* the program AST representation (inc. all imports and standard library) and runs it through a type checker, but

[go-nuts] Where is my memory in Linux?

2018-02-02 Thread Zhang Rui
Hello gophers, I have a VM on Linode.com. OS is Cent OS 6.8 and kernel is 4.14.12-x86_64-linode92. It has 1 CPU core and 2G RAM. A Go application is running on this VM. Free memory on this VM is 490M (with buffer and cache), The RSS value of this Go application is only 12M. After I kill this

[go-nuts] Re: Parse C/C++ source code?

2018-02-02 Thread roozbeh . farahbod
Hi Leff. Did you find anything good eventually? The cznic/cc code offers a decent compiler but I found it very bad to read and reuse. I don't want to rely on guess work and the documentation is almost non-existant. On Tuesday, May 17, 2016 at 12:37:25 PM UTC+2, Leff Ivanov wrote: > > Hello!

Re: [go-nuts] Rate controlling the Go http server

2018-02-02 Thread Henrik Johansson
You can either use one of the existing other routers that have meddleware support or you could wrap your handlers in another handler much like this: handle("/foo",wrapHandler(rateLimiter, realHandler)) func wrapHandler(limit *ARateLimiter, handler func(http.ResponseWriter, *http.Request))

Re: [go-nuts] Rate controlling the Go http server

2018-02-02 Thread Patrik Iselind
Den fredag 2 februari 2018 kl. 11:50:43 UTC+1 skrev Jesper Louis Andersen: > > A simple solution is to have a channel of type struct{} of some bound, say > 10. A process only gives service as long as it can pull a message from the > channel. > How would i hook in such a channel in the http

Re: [go-nuts] Rate controlling the Go http server

2018-02-02 Thread Patrik Iselind
Den fredag 2 februari 2018 kl. 11:50:22 UTC+1 skrev Henrik Johansson: > > I guess a middleware wrapping any of the available rate limiters > https://godoc.org/?q=rate+limit should do the trick? > Thanks a lot for your suggestion. How do i add middleware to the HTTP server in the first place? I

[go-nuts] Rate controlling the Go http server

2018-02-02 Thread Patrik Iselind
Hi, If i define a webserver as such (taken from the docs) http.Handle("/foo", fooHandler) http.HandleFunc("/bar", func(w http.ResponseWriter, r *http.Request) { fmt.Fprintf(w, "Hello, %q", html.EscapeString(r.URL.Path)) }) log.Fatal(http.ListenAndServe(":8080", nil)) How do i control

Re: [go-nuts] Rate controlling the Go http server

2018-02-02 Thread Henrik Johansson
I guess a middleware wrapping any of the available rate limiters https://godoc.org/?q=rate+limit should do the trick? fre 2 feb. 2018 kl 11:30 skrev Patrik Iselind : > Hi, > > If i define a webserver as such (taken from the docs) > > http.Handle("/foo", fooHandler) > >

Re: [go-nuts] Re: any discourse-like forum in Go?

2018-02-02 Thread Sebastien Binet
Hi, I believe the golangbridge forum is discourse with a (nice) Go theme. I'd be happy to be proven wrong though :) -s sent from my droid On Feb 2, 2018 9:30 AM, wrote: > Golang Bridge has a forum: https://forum.golangbridge.org/top > > On Wednesday, January 31, 2018 at

[go-nuts] Re: any discourse-like forum in Go?

2018-02-02 Thread kanepyork
Golang Bridge has a forum: https://forum.golangbridge.org/top On Wednesday, January 31, 2018 at 8:29:25 AM UTC-8, Sebastien Binet wrote: > > hi there, > > I am looking for a discourse-like forum, in Go. Does anybody know of such > a thing? > > Interestingly, reading the