Re: [go-nuts] Re: errors/wrap.go looks like it could be made into a more general monad package?

2019-07-02 Thread Gert
Fine I can change the name to wrapper no problem, but I do think there are cases where you have general types like for example xml and json and wrapped in types like html and geojson. I just think we going to be to late to realise that the new Unwrap Is As %w is very useful for other types too.

Re: [go-nuts] Re: The "leave "if err != nil" alone?" anti-proposal

2019-07-02 Thread Russtopia
Score one in support for this, from the "peanut gallery" of "experienced programmers in other languages, but only around 2 years of Go". I thought at first that if err != nil { ... } seemed clumsy, but I myself don't like exceptions and implicit flow control constructs much and the more I used Go,

Re: [go-nuts] Re: errors/wrap.go looks like it could be made into a more general monad package?

2019-07-02 Thread Michal Strba
First of all, this is not at all what "monad" means. A monad is a way to express threading of values between computations. A result of one computation gets threaded as an input to the next one, and so on. Second, what would be the use-case of this other than errors? On Wed, Jul 3, 2019, 04:52 Ger

[go-nuts] Re: errors/wrap.go looks like it could be made into a more general monad package?

2019-07-02 Thread Gert
On Wednesday, July 3, 2019 at 3:03:20 AM UTC+2, Gert wrote: > > https://github.com/golang/go/blob/master/src/errors/wrap.go > > What if we replaced all error types in that file with a empty interface or > a general monad interface? Can we make it work for other types too and > introduce a new mon

[go-nuts] Re: The "leave "if err != nil" alone?" anti-proposal

2019-07-02 Thread Dave Cohen
On Friday, June 28, 2019 at 5:44:01 PM UTC-7, Tyler Compton wrote: > > If anyone hasn't seen it, an issue with the "proposal" tag was created > earlier on the Go issue tracker titled "Proposal: leave "if err != nil" > alone?" (here ). This issue seems to > have

[go-nuts] Re: errors/wrap.go looks like it could be made into a more general monad package?

2019-07-02 Thread Gert
On Wednesday, July 3, 2019 at 3:03:20 AM UTC+2, Gert wrote: > > https://github.com/golang/go/blob/master/src/errors/wrap.go > > What if we replaced all error types in that file with a empty interface or > a general monad interface? Can we make it work for other types too and > introduce a new mon

[go-nuts] Re: errors/wrap.go looks like it could be made into a more general monad package?

2019-07-02 Thread Gert
On Wednesday, July 3, 2019 at 3:03:20 AM UTC+2, Gert wrote: > > https://github.com/golang/go/blob/master/src/errors/wrap.go > > What if we replaced all error types in that file with a empty interface or > a general monad interface? Can we make it work for other types too and > introduce a new mon

Re: [go-nuts] The "leave "if err != nil" alone?" anti-proposal

2019-07-02 Thread Ian Lance Taylor
On Tue, Jul 2, 2019 at 8:46 AM Space A. wrote: > > May I ask, where were those surveys and how this could happen that so many > ppl opinions left with no attention? The surveys were mentioned in a number of different forums, including this mailing list. The survey results can be found at https

[go-nuts] errors/wrap.go looks like it could be made into a more general monad package?

2019-07-02 Thread Gert
https://github.com/golang/go/blob/master/src/errors/wrap.go What if we replaced all error types in that file with a empty interface or a general monad interface? Can we make it work for other types too and introduce a new monad package instead a new error package only? -- You received this mes

Re: [go-nuts] "go build" breaks with go modules -- error messages says repo is trying to import itself...

2019-07-02 Thread 'Christopher Dang' via golang-nuts
yes. i was able to get it to work with "go build ./..." On Tue, Jul 2, 2019 at 2:56 PM Burak Serdar wrote: > On Tue, Jul 2, 2019 at 3:53 PM christopher.dang via golang-nuts > wrote: > > > > Hello, I'm migrating my codebase from dep to go modules. I'm able to run > go get ./... without any probl

Re: [go-nuts] "go build" breaks with go modules -- error messages says repo is trying to import itself...

2019-07-02 Thread Burak Serdar
On Tue, Jul 2, 2019 at 3:53 PM christopher.dang via golang-nuts wrote: > > Hello, I'm migrating my codebase from dep to go modules. I'm able to run go > get ./... without any problems but when I run go build I get the following > error message: > > can't load package: package github.com/WeConnec

[go-nuts] "go build" breaks with go modules -- error messages says repo is trying to import itself...

2019-07-02 Thread christopher.dang via golang-nuts
Hello, I'm migrating my codebase from dep to go modules. I'm able to run go get ./... without any problems but when I run go build I get the following error message: can't load package: package github.com/WeConnect/alpha: unknown import path "github.com/WeConnect/alpha": cannot find module prov

Re: [go-nuts] OOM occurring with a small heap

2019-07-02 Thread 'Yunchi Luo' via golang-nuts
Yeah, I've been looking at the goroutine profiles and there are some strange stacks like the below. 1 reflect.flag.mustBeExported /go/src/reflect/value.go:213 reflect.Value.call /go/src/reflect/value.go:424 reflect.Value.Call /go/src/reflect/value.go:308

[go-nuts] `on err` alternative to `try()` has traction...?

2019-07-02 Thread Liam
This proposal has attracted modest attention from the Go team... https://github.com/golang/go/issues/32611 It suggests: err := f() on err, on err, return err// any type can be tested for non-zero on err, return fmt.Errorf(...) on err, fmt.Println(err) // doesn't stop the funct

Re: [go-nuts] OOM occurring with a small heap

2019-07-02 Thread andrey mirtchovski
ok, this is interesting: reflect.MakeFunc: i've never done this before. what are the allocation patterns for creating functions with reflect? i see a few crashes related to these functions but no mentioning of severe memory consumption. in my opinion, trying to capture MakeFunc patterns from your

Re: [go-nuts] OOM occurring with a small heap

2019-07-02 Thread Bakul Shah
Switching Go version seems like a stab in the dark. If the OOM symptom does show up, you have simply wasted time. If it doesn't show up, you still don't know if the bug exists and is simply hiding. Even if you think the bug in Go code generation (or GC) and not in your code, there is nothing the

Re: [go-nuts] Parsing time zone +07:00

2019-07-02 Thread 'Константин Иванов' via golang-nuts
Thank you. вторник, 2 июля 2019 г., 22:26:39 UTC+4 пользователь mb0 написал: > > the format time uses a minus sign '-' instead of a plus > > https://play.golang.org/p/pXDXm0KmwTz > > have fun! > -- You received this message because you are subscribed to the Google Groups "golang-nuts" group

Re: [go-nuts] Parsing time zone +07:00

2019-07-02 Thread Martin Schnabel
the format time uses a minus sign '-' instead of a plus https://play.golang.org/p/pXDXm0KmwTz have fun! On 02.07.19 20:11, 'Константин Иванов' via golang-nuts wrote: https://play.golang.org/p/4Rr2xVGKnQg | packagemain import( "fmt" "time" ) constin="+03:00"// "2019-07-02T19:28:39.403+03:0

Re: [go-nuts] OOM occurring with a small heap

2019-07-02 Thread 'Yunchi Luo' via golang-nuts
I removed the httptrace call yesterday and there have been no OOMs yet. Going to let it bake for another day. If OOMs show up again, I'll try reverting to an older Go version tomorrow. Otherwise I'll point my finger at httptrace I guess. On Tue, Jul 2, 2019 at 2:15 PM Yunchi Luo wrote: > I did t

Re: [go-nuts] OOM occurring with a small heap

2019-07-02 Thread 'Yunchi Luo' via golang-nuts
I did try to do that! I have 3 heap profiles captured from the ~3 seconds before crash. The only thing particularly suspicious is the httptrace call I mentioned earlier in the thread. Diffing 1 to 2 (pprof) cum (pprof) top 50 Showing nodes accounting for 4604.15kB, 81.69% of 5636.17kB total

Re: [go-nuts] OOM occurring with a small heap

2019-07-02 Thread Robert Engels
Did you try running on an older release of Go, like 1.10? > On Jul 2, 2019, at 11:53 AM, 'Yunchi Luo' via golang-nuts > wrote: > > I'm not so much pointing my finger at GC as I am hoping GC logs could help > tell the story, and that someone with a strong understanding of GC in Go > could weig

[go-nuts] Re: Parsing time zone +07:00

2019-07-02 Thread 'Константин Иванов' via golang-nuts
*doing -- 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.c

[go-nuts] Parsing time zone +07:00

2019-07-02 Thread 'Константин Иванов' via golang-nuts
https://play.golang.org/p/4Rr2xVGKnQg package main import ( "fmt" "time" ) const in = "+03:00" // "2019-07-02T19:28:39.403+03:00" const TIME = "+07:00" // "2006-01-02T15:04:05.999+07:00" func main() { fmt.Println(time.Parse(TIME, in)) } Got << parsing time "+03:00" as "+07:00":

Re: [go-nuts] OOM occurring with a small heap

2019-07-02 Thread andrey mirtchovski
What I have found useful in the past is pprof's ability to diff profiles. That means that if you capture heap profiles at regular intervals you can see a much smaller subset of changes and compare allocation patterns. On Tue, Jul 2, 2019, 10:53 AM 'Yunchi Luo' via golang-nuts < golang-nuts@googleg

Re: [go-nuts] OOM occurring with a small heap

2019-07-02 Thread 'Yunchi Luo' via golang-nuts
I'm not so much pointing my finger at GC as I am hoping GC logs could help tell the story, and that someone with a strong understanding of GC in Go could weigh in here. In the last 4 seconds before OOM, "TotalAlloc" increased by only 80M, yet "HeapIdle" increased to 240M from 50M, RSS increased by

Re: [go-nuts] The "leave "if err != nil" alone?" anti-proposal

2019-07-02 Thread 'Bryan Mills' via golang-nuts
On Monday, July 1, 2019 at 3:12:24 AM UTC-4, Ian Lance Taylor wrote: > > Think about how you would write a basic Go construct like > https://godoc.org/golang.org/x/sync/errgroup if errors are handled via > exceptions. I'm not saying you can't do it--of course you can do it. > But it seems to me

Re: [go-nuts] The "leave "if err != nil" alone?" anti-proposal

2019-07-02 Thread Space A.
It's so nice when someone is facing audience of thousands of users by "where were you"? Maybe it's because they have not too much time to read all these forum threads, they just use the tool instead of talking, and also want to leave some time for a personal life? May I ask, where were those su

Re: [go-nuts] OOM occurring with a small heap

2019-07-02 Thread Mighty Guava
I don't understand. What would adding runtime.Goscheduled() do here? I don't have any explicit loops in this service. On Jul 1, 2019, 9:11 PM -0400, Michael Jones , wrote: > Does adding runtime.GoSched() calls make any difference? > > > On Mon, Jul 1, 2019 at 5:37 PM 'Yunchi Luo' via golang-nuts

[go-nuts] how http.Client to know if remote connections is closed

2019-07-02 Thread chengfa chen
I have write a program to download file from cloud. I find if the network is closed or reconnect, it will return error in windows. But if in linux, it won't get error, just download all the time. And I don't want to set http.Client timeout, because the net speed may slow, i don't know a appropr

Re: [go-nuts] OOM occurring with a small heap

2019-07-02 Thread Mighty Guava
I don't think GC is being blocked. GC ran multiple times during the time the service was exploding in memory. I'm not using mmap in the service. It's just a straightforward CRUD webserver backed by DynamoDB. The only thing non-standard I can think of is that it connects to its backing database

Re: [go-nuts] OOM occurring with a small heap

2019-07-02 Thread Mighty Guava
Oh now that you mention it, I'm using grpc-gateway with the stdlib http server. Though all it really does is convert json <=> protobuf and is pretty mature so it's unlikely to be the culprit. Running with race detector is a good idea! I'll try that tomorrow. Thanks, Yunchi Luo On Jul 2, 2019, 1

Re: [go-nuts] YAEHI (Yet another error-handling idea)

2019-07-02 Thread Andrey Tcherepanov
As sad as it sounds, inside of me I agree on "it is all moot anyway", but... Aren't we allowed to at least freely day-dream anyway :) ? I was thinking about it over weekend, and came with these "rules", but I need help on these for sure 1. If expression ends with ? (like func()?) , then it