Re: [go-nuts] Golang equivalent of Python's context manager

2018-09-12 Thread Justin Israel
On Thu, Sep 13, 2018, 10:13 AM Mirko Friedenhagen wrote: > Thanks again. I think some of the use cases, especially those which > implement some kind of finally (which includes locking use case) may just > be implemented with simple functions. At least throwing exceptions is a > rare event in Gola

[go-nuts] Re: http client POST/GET.. will not save cookie before do redirect request

2018-09-12 Thread Weeds Qian
If you look at my sample code, you should know I only send one request by http.POST, the following request is done by golang http client automaticly, not issue by myself. You got the point , why the http client do that without cookie from last response, that's what I am asking 在 2018年9月12日星期三

Re: [go-nuts] Go memory usage inside containers

2018-09-12 Thread robert engels
This may be of interest. https://lists.linuxfoundation.org/pipermail/containers/2012-May/029798.html https://www.spinics.net/lists/cgroups/msg16842.html https://gi

Re: [go-nuts] Scrapping contracts (was: "Generics as bultin typeclasses")

2018-09-12 Thread robert engels
I think the idea of ‘field accessors’ is kind of scary. It is used all of the time in Java, but it happens there because Java has classes , so the generic can use a base class as a type - although most people do not do this for obvious reasons. Go interfaces only have methods. If generics are b

Re: [go-nuts] Go memory usage inside containers

2018-09-12 Thread Wojciech S. Czarnecki
On Tue, 11 Sep 2018 23:48:03 -0700 (PDT) Leigh McCulloch wrote: > Hi, > > Does anyone here know how Go interacts with memory limits inside > containers? (e.g. Kubernetes, Docker) Real box info - parse /proc/meminfo Inside Docker: use stats via socket. Mount /var/run/docker.sock into your contai

Re: [go-nuts] Scrapping contracts (was: "Generics as bultin typeclasses")

2018-09-12 Thread Jonathan Amsterdam
Not to be snide, but we are looking for examples, not kinds of examples. Do you know of actual code where this would benefit? For example, could field accessors improve the standard image and image/color packages? On Wednesday, September 12, 2018 at 9:15:24 AM UTC-4, Mandolyte wrote: > > On fi

Re: [go-nuts] Golang equivalent of Python's context manager

2018-09-12 Thread Mirko Friedenhagen
Thanks again. I think some of the use cases, especially those which implement some kind of finally (which includes locking use case) may just be implemented with simple functions. At least throwing exceptions is a rare event in Golang (panicking is what I meant with rare). Are closures, like th

Re: [go-nuts] Go memory usage inside containers

2018-09-12 Thread Henrik Johansson
taskset works for sure and I managed to crash a program with ulimit. I thought these stuff was what the container runtimes used under the hood. Am I missing something? ons 12 sep. 2018 kl 16:14 skrev Ian Lance Taylor : > On Wed, Sep 12, 2018 at 7:07 AM, robert engels > wrote: > > With the Azul V

[go-nuts] Re: Go modules: go get installs binary

2018-09-12 Thread 'Bryan Mills' via golang-nuts
Per the documentation , “Get resolves and adds dependencies to the current development module and then builds and installs them.” If you want it to only update dependencies, use the -m flag; to only update and download, use -d. On Sunda

Re: [go-nuts] Generics - Min challenge

2018-09-12 Thread Wojciech S. Czarnecki
On Wed, 12 Sep 2018 10:05:06 -0700 Ian Lance Taylor wrote: > a compile-time decision as to which code should be compiled. Note that this decision making is needed only for outstanding cases usually in user own code. For many generic implementation a simple for type contract is enough: // Sum met

Re: [go-nuts] Golang equivalent of Python's context manager

2018-09-12 Thread Justin Israel
For about the same amount of typing that you have to do to create a closure for using with a predefined WithContext handler, I tend to do this inline: func start() { fmt.Println("start") } func stop() { fmt.Println("stop") } func main() { func() (string, error) { start() defer

Re: [go-nuts] Generics - Min challenge

2018-09-12 Thread Wojciech S. Czarnecki
On Wed, 12 Sep 2018 10:05:06 -0700 Ian Lance Taylor wrote: > I agree that no code is produced by the program, but you're suggesting > a compile-time decision as to which code should be compiled. How does it differ from unused code eliding go compiler and linker do already? Used `for type case`

Re: [go-nuts] golang gRPC question

2018-09-12 Thread Robert Engels
The streaming mechanism seems to be the solution. Appears to be how cockroachdb does it. Sent from my iPhone > On Sep 12, 2018, at 2:47 PM, Josh Humphries wrote: > > >> On Wed, Sep 12, 2018 at 9:05 AM robert engels wrote: >> Hi, I am adding a remote component to my github.com/robaho/keydb p

Re: [go-nuts] golang gRPC question

2018-09-12 Thread Josh Humphries
On Wed, Sep 12, 2018 at 9:05 AM robert engels wrote: > Hi, I am adding a remote component to my github.com/robaho/keydb project > and decided to use gRPC. > > I’ve reviewed the docs, and it appears to want to be stateless - which > given the nature of Google makes sense. > > But for something lik

Re: [go-nuts] Golang equivalent of Python's context manager

2018-09-12 Thread Sam Whited
On Wed, Sep 12, 2018, at 14:12, Mirko Friedenhagen wrote: > However, coming from Java lately, retrieving a DB-connection from a pool, > opening a transaction and committing/aborting and returningafterwards seems > something which could be handled with such a construct. How would you do > this in

[go-nuts] Re: golang gRPC question

2018-09-12 Thread Tamás Gulácsi
2018. szeptember 12., szerda 15:05:43 UTC+2 időpontban Robert Engels a következőt írta: > > Hi, I am adding a remote component to my github.com/robaho/keydb project > and decided to use gRPC. > > I’ve reviewed the docs, and it appears to want to be stateless - which > given the nature of Google

Re: [go-nuts] Golang equivalent of Python's context manager

2018-09-12 Thread Mirko Friedenhagen
First of all, thanks for all the answers. A standard use case in Python is to use with the a closing context manager which will just call close on a given object. That one could be easily done with a defer statement. However, coming from Java lately, retrieving a DB-connection from a pool, open

Re: [go-nuts] Re: Generic types - functions and methods on instantions

2018-09-12 Thread Patrick Smith
On Wed, Sep 12, 2018 at 7:49 AM Ian Lance Taylor wrote: > On Tue, Sep 11, 2018 at 5:38 PM, Patrick Smith > wrote: > > First, please consider requiring the 'type' keyword in definitions of > > methods on generic types: > > > > func (x Foo(type T)) method() {} > > > Interesting idea, but even if w

Re: [go-nuts] Generics - Min challenge

2018-09-12 Thread Patrick Smith
On Wed, Sep 12, 2018 at 6:34 AM Ian Lance Taylor wrote: > That said, if we move forward with something like contracts, I think > that it may be possible to introduce contract adaptors in the future: > a mechanism that says "if the type argument does not implement > contract C1, but does implement

Re: [go-nuts] A thought on contracts

2018-09-12 Thread Larry Clapp
> > we should have a tool that, given a contract body, produces a minimal > contract body that expresses the same contract. And run it on save, like gofmt. Or just make it part of gofmt. On Thursday, September 6, 2018 at 4:22:34 PM UTC-4, Ian Lance Taylor wrote: > > On Wed, Sep 5, 2018 at 8:2

Re: [go-nuts] A thought on contracts

2018-09-12 Thread Ian Lance Taylor
On Mon, Sep 10, 2018 at 5:32 AM, komuW wrote: > > On Thursday, 6 September 2018 23:22:34 UTC+3, Ian Lance Taylor wrote: >> >> On Wed, Sep 5, 2018 at 8:26 PM, Steve Phillips wrote: >> > Interesting idea, but has the Go team expressed interest in creating >> > such a tool? >> >> Yes, I think it's b

Re: [go-nuts] Generics - Why contracts?

2018-09-12 Thread Eric S. Raymond
alanfo : > I suspect that you could achieve 90% coverage with just 4 built-in > contracts: > > > 1. integer (any integer type) > > 2. real (any integer or floating point type) > > 3. ordered (any integer, floating point or string type) > > 4. comparable (any type which supports == and !=)

Re: [go-nuts] Contracts and fused multiply add

2018-09-12 Thread jimmy frasche
On Wed, Sep 12, 2018 at 11:02 AM Ian Lance Taylor wrote: > You could perhaps choose an implementation based on unsafe.Sizeof. > But I agree that it's pretty ugly. Only if the contract were t * t + t < .1 Part of the construction was that it accepted more than just floating points. -- You recei

Re: [go-nuts] Contracts and fused multiply add

2018-09-12 Thread Ian Lance Taylor
On Wed, Sep 12, 2018 at 10:54 AM, jimmy frasche wrote: > > Given a platform that supports the fused multiply add (FMA) > instruction and the code: > > contract MA(t T) { > t * t + t > } > > func ma(type T MA)(a, b, c T) T { > return a*b + c > } > > Does the compiled-for-any-type ve

[go-nuts] Contracts and fused multiply add

2018-09-12 Thread jimmy frasche
Given a platform that supports the fused multiply add (FMA) instruction and the code: contract MA(t T) { t * t + t } func ma(type T MA)(a, b, c T) T { return a*b + c } Does the compiled-for-any-type version support the FMA optimization when called with a floating-point type? If

Re: [go-nuts] Generics - Min challenge

2018-09-12 Thread Michael Jones
Compile-time logic feels like a baby/bathwater issue to me. With M4 and then CPP on the scene, new kinds of adaptable code became possible in C. It was such a compelling benefit (I still have the CSTRs) that it grew to ubiquity and finally to a monsterous horror in C++ that in recent decades, thro

[go-nuts] Re: Generics - Why contracts?

2018-09-12 Thread jake6502
Some of the reasons for contracts have been covered by others in this thread already. But somehow one of the biggest has not. Contracts make it possible to change the implementation of a generic function in a published package. Without a contract it would be super easy for a seemingly simple ch

Re: [go-nuts] Generics - Min challenge

2018-09-12 Thread Ian Lance Taylor
On Wed, Sep 12, 2018 at 7:49 AM, Wojciech S. Czarnecki wrote: > On Wed, 12 Sep 2018 06:33:59 -0700 > Ian Lance Taylor wrote: > > Addenum: > >> You need to have a way to say "compile this code under certain >> conditions based on the type argument, otherwise compile this code." >> That is, the co

Re: [go-nuts] Generics - Min challenge

2018-09-12 Thread Wojciech S. Czarnecki
On Wed, 12 Sep 2018 07:40:37 -0700 Ian Lance Taylor wrote: > The difference I see is that in one case we write code that can not be > compiled, and then tell the compiler not to compile it. > we direct the compiler to automatically insert wrappers that > make the type fit the contract. Who is s

Re: [go-nuts] Generics "craftsman approach" proposal update

2018-09-12 Thread Wojciech S. Czarnecki
On Wed, 12 Sep 2018 07:05:55 -0700 Ian Lance Taylor wrote: > I don't see a description of generic types, I only see generic functions. CGG in its current shape does not allow for **declaring** generic named types out of thin air. But it allows for instantiating such types (now p 3.2 in draft):

Re: [go-nuts] Generics - Min challenge

2018-09-12 Thread Wojciech S. Czarnecki
On Wed, 12 Sep 2018 06:33:59 -0700 Ian Lance Taylor wrote: Addenum: > You need to have a way to say "compile this code under certain > conditions based on the type argument, otherwise compile this code." > That is, the compiler is directed, at compile time, as to which code > should be compiled

Re: [go-nuts] Re: Generic types - functions and methods on instantions

2018-09-12 Thread Ian Lance Taylor
On Tue, Sep 11, 2018 at 5:38 PM, Patrick Smith wrote: > > First, please consider requiring the 'type' keyword in definitions of > methods on generic types: > > func (x Foo(type T)) method() {} > > This adds a small amount of verbiage, but makes the intent crystal clear. It > also allows for easy e

Re: [go-nuts] Generics - Min challenge

2018-09-12 Thread Ian Lance Taylor
On Wed, Sep 12, 2018 at 7:32 AM, Wojciech S. Czarnecki wrote: > On Wed, 12 Sep 2018 06:33:59 -0700 > Ian Lance Taylor wrote: > >> I don't think there is any way to solve this problem as stated without >> taking a step toward metaprogramming: making decisions at compile time. > > Excuse me, how an

Re: [go-nuts] Generics - Min challenge

2018-09-12 Thread Wojciech S. Czarnecki
On Wed, 12 Sep 2018 06:33:59 -0700 Ian Lance Taylor wrote: > I don't think there is any way to solve this problem as stated without > taking a step toward metaprogramming: making decisions at compile time. Excuse me, how and where below stated artificial "contract adaptors" are NOT "making decis

Re: [go-nuts] Go memory usage inside containers

2018-09-12 Thread Ian Lance Taylor
On Wed, Sep 12, 2018 at 7:07 AM, robert engels wrote: > With the Azul VM (and I believe the G1 collector in Java), the VM is > definitely aware of memory pressure as it approaches the maximum limit - then > it will increase the concurrent GC activity trying to avoid a potential huge > pause if

Re: [go-nuts] Go memory usage inside containers

2018-09-12 Thread Ian Lance Taylor
On Wed, Sep 12, 2018 at 6:58 AM, Leigh McCulloch wrote: > > Thanks for the link and answering. I'll look more into understanding the > issue. I'm mostly trying to reconcile that there are so many articles about > not using Java inside containers because it does nothing to stay in the > memory limi

Re: [go-nuts] Re: Scrapping contracts (was: "Generics as bultin typeclasses")

2018-09-12 Thread 'Axel Wagner' via golang-nuts
On Wed, Sep 12, 2018 at 3:55 PM Tristan Colgate wrote: > I'll leave the grown up to discuss after this I promise) > Don't worry. I'm not grown up by any measure. > I guess if I were going to critique this I would say that optimising for > ease of compiler implementation may not be the best thi

Re: [go-nuts] Go memory usage inside containers

2018-09-12 Thread robert engels
You would need to refer me to those articles. We used Java in containers all of the time. You need to set a proper -Xmx though. > On Sep 12, 2018, at 9:07 AM, robert engels wrote: > > With the Azul VM (and I believe the G1 collector in Java), the VM is > definitely aware of memory pressure as

Re: [go-nuts] Go memory usage inside containers

2018-09-12 Thread robert engels
With the Azul VM (and I believe the G1 collector in Java), the VM is definitely aware of memory pressure as it approaches the maximum limit - then it will increase the concurrent GC activity trying to avoid a potential huge pause if the limit was reached - so throughput is lowered. I would thin

Re: [go-nuts] Generics "craftsman approach" proposal update

2018-09-12 Thread Ian Lance Taylor
On Wed, Sep 12, 2018 at 6:47 AM, Wojciech S. Czarnecki wrote: > > https://github.com/ohir/gonerics > > Thanks to all for your insights and stated concerns. > > Changes: > > 1. "Out" (return) type constraints are out. Might return as optional. > 2. enumerated "T is assignable to" constraint added >

Re: [go-nuts] [golang-dev] go doesn't need generics, but if they do...

2018-09-12 Thread robert engels
By the way, see the following quote and this page https://www.bytonic.de/html/benchmarks.html and this quote, " November 28, 2005. Retrieved July 18, 2009. This is a great show of 3D prowess. Things like this, as well as the Narya 2D open source eng

Re: [go-nuts] Go memory usage inside containers

2018-09-12 Thread Leigh McCulloch
Hi Ian, Thanks for the link and answering. I'll look more into understanding the issue. I'm mostly trying to reconcile that there are so many articles about not using Java inside containers because it does nothing to stay in the memory limits, but then I see no other articles about Go, giving t

Re: [go-nuts] Re: Scrapping contracts (was: "Generics as bultin typeclasses")

2018-09-12 Thread Tristan Colgate
(I'm acutely aware that there's a limit to how useful endless back and forth on this stuff is, and I definitely have to yield on the technical details here, I'll leave the grown up to discuss after this I promise) On Tue, 11 Sep 2018 at 14:26 Axel Wagner wrote: > There is no accounting for taste

[go-nuts] Generics "craftsman approach" proposal update

2018-09-12 Thread Wojciech S. Czarnecki
https://github.com/ohir/gonerics Thanks to all for your insights and stated concerns. Changes: 1. "Out" (return) type constraints are out. Might return as optional. 2. enumerated "T is assignable to" constraint added 3. "Rationale" clarified. -- Wojciech S. Czarnecki << ^oo^ >> OHIR-RIPE --

Re: [go-nuts] Go memory usage inside containers

2018-09-12 Thread Ian Lance Taylor
On Tue, Sep 11, 2018 at 11:48 PM, Leigh McCulloch wrote: > > Does anyone here know how Go interacts with memory limits inside containers? > (e.g. Kubernetes, Docker) > > Does the Go runtime have similar problems as the Java runtime, in that it > doesn't know what the container limit is, and only

[go-nuts] Re: I want to run a go project called syncthing on iOS , but I have some issues

2018-09-12 Thread m18742049357
I got the project from https://github.com/pangliang/syncthing-ios ,it can work 2years ago, and the synching.a can be used now. 在 2018年9月12日星期三 UTC+8下午8:58:01,Elias Naur写道: > > Tamás is right: go install or go build should be enough. Mare sure you > have a recent version of Xcode (I use version

Re: [go-nuts] Golang equivalent of Python's context manager

2018-09-12 Thread robert engels
Agree it can be done - not sure I would want to maintain that in a large system as you are paying the LOC penalty at every call site. Seems easier to just add the context callback in the methods themselves so then you are in control of the code penalty. > On Sep 12, 2018, at 8:17 AM, Sebastien

Re: [go-nuts] Re: [golang-dev] go doesn't need generics, but if they do...

2018-09-12 Thread robert engels
While I always appreciate a good presentation, a little color might be in order to get me to watch a 1.5 hr presentation. I’ll disagree on ByteBuffer. The prime motivation for ByteBuffer was to abstract the concept of a memory buffer (usually bytes). The primary reason is that byte[] has a defi

Re: [go-nuts] Generics - Min challenge

2018-09-12 Thread Ian Lance Taylor
On Tue, Sep 11, 2018 at 6:22 PM, Patrick Smith wrote: > > This is a hypothetical question. Suppose generics were implemented as in the > draft proposal, but without contracts. Instead, the rule is that if an > instantiation of a generic function with a specific type argument doesn't > compile, the

Re: [go-nuts] Re: Scrapping contracts (was: "Generics as bultin typeclasses")

2018-09-12 Thread Tristan Colgate
On Tue, 11 Sep 2018, 18:12 jimmy frasche, wrote: > Using the interface type to constrain type parameters at compile-time > does not necessarily imply using the interface value to implement > generics at runtime. No, but this does imply that we override what an interface is. They are already one

Re: [go-nuts] Scrapping contracts (was: "Generics as bultin typeclasses")

2018-09-12 Thread Tristan Colgate
I think the point is that by implementing Getter/Setter methods, which are trivially inline-able there's no real downside to skipping fields and just allowing method calls. If it makes it easier to unify contracts and interfaces, I think that may be a hit worth taking (though I still say, getters a

Re: [go-nuts] Golang equivalent of Python's context manager

2018-09-12 Thread Sebastien Binet
On Wed, Sep 12, 2018 at 2:55 PM robert engels wrote: > Ok, now the coffee has kicked in, and it still has problems, because you > cannot call a method and use a return value other than error without > multiple signatures, unless you move all of the return values outside of > the closure - like hi

Re: [go-nuts] Scrapping contracts (was: "Generics as bultin typeclasses")

2018-09-12 Thread Mandolyte
On field accessors... - Algorithms for X,Y points requiring them to be members of a struct type. - Algorithms to manipulate colors, requiring R,G, and B to be members. In an image processing library with its own rich set of struct types, such accessors would prove productive. Are these the ki

Re: [go-nuts] Re: [golang-dev] go doesn't need generics, but if they do...

2018-09-12 Thread Egon
On Wednesday, 12 September 2018 15:47:14 UTC+3, Robert Engels wrote: > > I am well aware of mechanical sympathy and the techniques (like the > disrupter) used (I would counter that in many cases you are not writing > “Java” due to the object pooling ,etc.) > > What I’ve shown is that Java is alre

[go-nuts] golang gRPC question

2018-09-12 Thread robert engels
Hi, I am adding a remote component to my github.com/robaho/keydb project and decided to use gRPC. I’ve reviewed the docs, and it appears to want to be stateless - which given the nature of Google makes sense. But for something like a database connection, where t

[go-nuts] Re: I want to run a go project called syncthing on iOS , but I have some issues

2018-09-12 Thread Elias Naur
Tamás is right: go install or go build should be enough. Mare sure you have a recent version of Xcode (I use version 9.x) installed. Here's my attempt: $ go get -u github.com/syncthing/syncthing/cmd/syncthing $ GOARCH=arm64 CGO_ENABLED=1 ~/go-tip/bin/go build -tags ios -o syncthing github.com/s

Re: [go-nuts] Golang equivalent of Python's context manager

2018-09-12 Thread robert engels
Ok, now the coffee has kicked in, and it still has problems, because you cannot call a method and use a return value other than error without multiple signatures, unless you move all of the return values outside of the closure - like his example does with var a. This would be extremely tedious

Re: [go-nuts] Golang equivalent of Python's context manager

2018-09-12 Thread robert engels
Too early, and the coffee had not kicked in... > On Sep 12, 2018, at 7:49 AM, robert engels wrote: > > Yes, you are correct. My bad :) > >> On Sep 12, 2018, at 7:34 AM, Sebastien Binet > > wrote: >> >> >> >> On Wed, Sep 12, 2018 at 2:23 PM robert engels >

Re: [go-nuts] Golang equivalent of Python's context manager

2018-09-12 Thread robert engels
Yes, you are correct. My bad :) > On Sep 12, 2018, at 7:34 AM, Sebastien Binet wrote: > > > > On Wed, Sep 12, 2018 at 2:23 PM robert engels > wrote: > I am pretty sure that is not correct, I am referring to: > >> func WithContext(context Context, f func() error)

[go-nuts] Re: I want to run a go project called syncthing on iOS , but I have some issues

2018-09-12 Thread m18742049357
I tried to use "go install" but I got the same probrom. I'm the first time using golang.I think if I have set the wrong go environment.But I set go environment for at least eight times. I want to konw if I can run go project on iOS.I am a little sad. 在 2018年9月12日星期三 UTC+8下午2:18:51,Tamás Gulácsi写道:

Re: [go-nuts] Re: [golang-dev] go doesn't need generics, but if they do...

2018-09-12 Thread robert engels
I am well aware of mechanical sympathy and the techniques (like the disrupter) used (I would counter that in many cases you are not writing “Java” due to the object pooling ,etc.) What I’ve shown is that Java is already more performant than Go without using those techniques for many application

Re: [go-nuts] Golang equivalent of Python's context manager

2018-09-12 Thread Sebastien Binet
On Wed, Sep 12, 2018 at 2:23 PM robert engels wrote: > I am pretty sure that is not correct, I am referring to: > > func WithContext(context Context, f func() error) error { > context.__entry__() > defer context.__exit__() > return f() > } > > > You will need a lot of WithContext methods - based

[go-nuts] Go Developer contract opportunity at a Digital Ventures/Start-up Hub : backed by FTSE100 company

2018-09-12 Thread alfie
Hi, I'm a recruiter currently looking for Go developers to join a really innovative team working on market disruptive products, based in Central London. It's a contract opportunity for 6 months with strong cope of extensions, offering a negotiable day rate that depends on experience (ideally c.

Re: [go-nuts] Golang equivalent of Python's context manager

2018-09-12 Thread robert engels
I am pretty sure that is not correct, I am referring to: > func WithContext(context Context, f func() error) error { > context.__entry__() > defer context.__exit__() > return f() > } You will need a lot of WithContext methods - based on the different signatures of function f.

Re: [go-nuts] Go memory usage inside containers

2018-09-12 Thread robert engels
I don’t think Java needs visibility into the max memory, as you need to set it via args (-Xmx) if you want a max - otherwise it will just keep allocation as it needs it - if an allocation from the OS fails, it will attempt a final GC to see if it can get more room, and if not, OOME. The Runtime

Re: [go-nuts] Golang equivalent of Python's context manager

2018-09-12 Thread Sebastien Binet
On Wed, Sep 12, 2018 at 2:10 PM robert engels wrote: > I think it would be problematic, as the callee signature is limited - > func() error - and with lack of method overloading you will need a lot of > With methods… > apart from the non-Go idiomatic names for the enter/exit interface method

Re: [go-nuts] Golang equivalent of Python's context manager

2018-09-12 Thread robert engels
I think it would be problematic, as the callee signature is limited - func() error - and with lack of method overloading you will need a lot of With methods… > On Sep 12, 2018, at 6:58 AM, Mirko Friedenhagen wrote: > > Hello, > > in Python I may define context managers which do stuff befo

[go-nuts] Golang equivalent of Python's context manager

2018-09-12 Thread Mirko Friedenhagen
Hello, in Python I may define context managers which do stuff before and after an action has taken place. E.g.: ``` class MyContext(object): def __enter__(self): print("Entering context") def __exit__(self, extype_unused, value_unused, traceback_unused): print("Exiting c

Re: [go-nuts] Generics - Min challenge

2018-09-12 Thread 'Axel Wagner' via golang-nuts
ISTM that your requirements can't work. 2) and 3) imply that the expression `x < y` with x,y of type T has to appear at least once in the function body, which means it can never work for a type that doesn't have it. I don't think that has anything to do with changing the type-checking rules though

Re: [go-nuts] Generics - Min challenge

2018-09-12 Thread Wojciech S. Czarnecki
On Tue, 11 Sep 2018 18:22:12 -0700 Patrick Smith wrote: > I'm fairly sure there's no way to write Min, but perhaps someone can prove > me wrong? Within "Craftsman Go Generics" proposal its trivial: func Min(a, b T) T { for type switch { case T func(T) Less(T) T: return a.Less(b) }

Re: [go-nuts] Go memory usage inside containers

2018-09-12 Thread Henrik Johansson
Afaik it works fine for Go programs as long as these limits translates to things like taskset etc. ons 12 sep. 2018 kl 08:48 skrev Leigh McCulloch : > Hi, > > Does anyone here know how Go interacts with memory limits inside > containers? (e.g. Kubernetes, Docker) > > Does the Go runtime have sim