Re: [go-nuts] Locking goroutine to "main" thread

2019-12-17 Thread Alex Buchanan
Yep. My understanding of locking the OS thread from an init() was wrong. I think I have it working now. Thanks guys! On Tue, Dec 17, 2019, at 9:37 AM, Ian Davis wrote: > > > On Sat, 14 Dec 2019, at 7:51 PM, bucha...@gmail.com wrote: >> If I understand correctly, that would prevent me from start

[go-nuts] multiple vendored x/net causing trouble (x/net/trace panic)

2018-05-07 Thread Alex Buchanan
This panic has caused me trouble many times over the last year: panic: http: multiple registrations for /debug/requests goroutine 1 [running]: net/http.(*ServeMux).Handle(0x5c47ba0, 0x511cbc5, 0xf, 0x5223160, 0x515f730) /usr/local/go/src/net/http/server.go:2353 +0x239 net/http.(*ServeMux).Handle

[go-nuts] [ANN] github release notes builder, based on PR history

2018-03-27 Thread Alex Buchanan
I created a simple utility to build release notes based on github pull request history, if anyone finds it useful: https://github.com/buchanae/github-release-notes Example results: https://github.com/ohsu-comp-bio/funnel/releases/tag/0.6.0 Cheers. -- You received this message because you are

[go-nuts] Re: How to lowercase all field names for MarshalJSON and UnmarshalJSON?

2018-03-05 Thread Alex Buchanan
Thanks, that does look helpful, although I'll need to evaluate the tradeoffs of not using the std lib. It's hard to believe a library could be substantially faster than the stdlib without giving something up. On Monday, March 5, 2018 at 9:52:04 PM UTC-8, Tamás Gulácsi wrote: > > You can try git

[go-nuts] Re: How to lowercase all field names for MarshalJSON and UnmarshalJSON?

2018-03-05 Thread Alex Buchanan
I'm bummed there still isn't a good solution for this. It seems like such an easy and extremely common thing. In a decade of webdev, I've possibly never seen a JSON API with Golang style UpperCamelCase keys. Is there a solution to this that I'm missing? Here's one project I'm working on where

[go-nuts] Re: unused import and variables, necessary at compiler level? Experience can be improved?

2018-02-01 Thread Alex Buchanan
Clever workarounds! These solutions don't handle the case of commenting out a function call, which is a common need IMO. Whatever the workaround, it would still be easier if done by vet, right? On Wednesday, January 31, 2018 at 6:46:40 PM UTC-8, Alex Buchanan wrote: > > Unused va

[go-nuts] Re: Unit tests - same vs separate package

2018-01-31 Thread Alex Buchanan
FWIW, I did not know about this line: "Test files that declare a package with the suffix "_test" will be compiled as a separate package, and then linked and run with the main test binary." In order to write integration/e2e tests while avoiding import cycles, most (not all) of our tests live in

[go-nuts] unused import and variables, necessary at compiler level? Experience can be improved?

2018-01-31 Thread Alex Buchanan
Unused variables and imports are strictly disallowed by the Go compiler. Most of the time, I enjoy this benefit. These days, I've started to notice how often things go dead and/or unused in my python code. But, sometimes, this behavior is incredibly annoying. If I'm trying to debug something by

Re: [go-nuts] Best way to add retries to existing library using net/http.Client?

2017-12-11 Thread Alex Buchanan
re we define all new > functionality as an `http.RoundTripper` and apply it with a > `func(http.RoundTripper) http.RoundTripper`. Ex: > > var client = &http.Client{ > Transport: Retry(TImeout(Log(&http.Transport{}))), > } > > On Sun, Dec 10, 2017 at 1:19 PM Alex Buc

[go-nuts] Best way to add retries to existing library using net/http.Client?

2017-12-10 Thread Alex Buchanan
I'm considering adding http client retries to an existing library, owned by someone else, in order to add resiliency to errors such as http 503. I'd like to keep the changes as minimal as possible, with maximum effect, as usual. I'm eyeing http.Client.Transport. Possibly I could use that to wrap

[go-nuts] Re: How to download a compressed S3 object ? example ( abc.zip )

2017-11-21 Thread Alex Buchanan
Here's some example s3 client code we use in Funnel: https://github.com/ohsu-comp-bio/funnel/blob/master/storage/s3.go And Amazon's S3 client docs: https://godoc.org/github.com/aws/aws-sdk-go/service/s3#hdr-Download_Manager Or, if you meant non-Amazon s3, we have some experience with minio: ht

Re: [go-nuts] Re: context.C and context.BG

2017-11-18 Thread Alex Buchanan
On Saturday, November 18, 2017 at 1:54:51 PM UTC-8, Axel Wagner wrote: > > Given that there should be exactly one call to context.Background per > binary (in func main()), I don't understand the problem this is trying to > solve. Similarly, context.TODO might be used, but should be used > tempo

Re: [go-nuts] Re: context.C and context.BG

2017-11-18 Thread Alex Buchanan
t what makes sense? context.TODO and >> context.Background are two different contexts and should be treated as such. >> >> >> On Friday, November 17, 2017 at 10:43:29 AM UTC-5, Alex Buchanan wrote: >>> >>> I don't have numbers, but context must be one

[go-nuts] Re: test debugging woes

2017-11-17 Thread Alex Buchanan
Some ideas: - I assume the code isn't public? If it is, you might share it - Are you running `go test -v` for verbose logging? - Try fmt.Printf - Try adding printing lines at points down the stack leading up to the point you think is failing, to make sure the code is actually running. - Put a log

[go-nuts] context.C and context.BG

2017-11-17 Thread Alex Buchanan
I don't have numbers, but context must be one of the most commonly used imports/types in my code. It shows up many function signatures. We try to use it for all cancelation. Would it make sense to add an alias "C" to the type "Context"? And maybe "BG" for Background()? Also, is there a specif

Re: [go-nuts] import a "main" package

2017-10-24 Thread Alex Buchanan
CLI command. Hope that made sense. Probably too late to be writing about such things :) On 10/24/17, 9:31 PM, "Ian Lance Taylor" wrote: >On Tue, Oct 24, 2017 at 8:14 PM, Alex Buchanan wrote: >> >> Is there documentation (or other) explaining why the main package must

Re: [go-nuts] import a "main" package

2017-10-24 Thread Alex Buchanan
Is there documentation (or other) explaining why the main package must have name "main" and may not be imported? Is this an important simplification for the compiler? I'd love it if a single "go get " represented both my library root and my command line binary. On Sunday, September 24, 2017 at

[go-nuts] Re: Any way to somehow include readable source code into compiled binaries?

2017-10-19 Thread Alex Buchanan
But, maybe a better solution is to faithfully record the current git (or other VCS) details you'd need to find the code which resulted in the binary? That way you have access to the source in its natural state. On Thursday, October 19, 2017 at 11:49:39 AM UTC-7, Alex Buchanan wrote: >

[go-nuts] Re: Any way to somehow include readable source code into compiled binaries?

2017-10-19 Thread Alex Buchanan
We use go-bindata to bundle text files (html, js, css, yaml) into our binary. I bet you could use it to bundle Go source. https://github.com/jteeuwen/go-bindata -Alex On Thursday, October 19, 2017 at 9:46:37 AM UTC-7, Samuel Lampa wrote: > > Hi Gophers, > > *Question:* Is there any way to inclu

[go-nuts] Re: log. Sprintf

2017-10-18 Thread Alex Buchanan
You mean fmt.Fprintf right? Formatting a string without writing to a io.Writer (fmt.Sprintf) must be safe for concurrent use. The "log" package should be safe for concurrent use, and has a Printf function: https://godoc.org/log#Logger """ A Logger represents an active logging object that genera

[go-nuts] Re: Task scheduler as a library?

2017-10-17 Thread Alex Buchanan
> > > Having tried using things like gleam/glow (see > https://github.com/chrislusf/gleam) and dask (which has similar ideas but > written in python) it sounds like a FIFO work stealing type scheduler > wouldn't be a bad idea. In particular dask's approach is quite nicely put > together. Thoug

Re: [go-nuts] Re: concurrent write-only to map ok?

2017-10-16 Thread Alex Buchanan
ithm, but it doesn't explain it very well. On Monday, October 16, 2017 at 9:42:18 AM UTC-7, Bryan Mills wrote: > > On Sunday, October 15, 2017 at 1:45:06 PM UTC-4, Alex Buchanan wrote: >> >> Show me the code! :) >> >> Here's mine: https://play.golang.org/

[go-nuts] Re: Task scheduler as a library?

2017-10-15 Thread Alex Buchanan
ostic way. It may be worth your while to take a look at the golang > bindings for drmaa so you aren't left reinventing the wheel. Maybe creating > a dumb scheduler for drmaa library might be the way to go? > > On Wednesday, 11 October 2017 20:14:46 UTC+1, Alex Buchanan wrote: >&

Re: [go-nuts] Re: concurrent write-only to map ok?

2017-10-15 Thread Alex Buchanan
Show me the code! :) Here's mine: https://play.golang.org/p/ZwAlu5VuYr -- 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.

[go-nuts] ld warnings with Go 1.9

2017-10-14 Thread Alex Buchanan
I tried Go 1.9.1 today, but got strange warnings from ld. Asking here before filing an issue as a sanity check in case my system is just borked somehow. ld: warning: object file (/var/folders/kw/m6dz8snx7h33ppbkbllnqt48bkhsqx/T/go-link-991847961/00.o) was built for newer OSX version (10.11

[go-nuts] Re: concurrent write-only to map ok?

2017-10-13 Thread Alex Buchanan
So many good answers! Lots of different ways to accomplish this. I'll say that in this specific case, which is does not require every ounce of performance, syncmap is by far the simplest and least amount of code, so readability wins on this one. -- You received this message because you are sub

Re: [go-nuts] concurrent write-only to map ok?

2017-10-13 Thread Alex Buchanan
Thanks for the quick help guys! I ended up using https://godoc.org/golang.org/x/sync/syncmap On Friday, October 13, 2017 at 11:22:44 AM UTC-7, Shawn Milochik wrote: > > On Fri, Oct 13, 2017 at 2:05 PM, Alex Buchanan > wrote: > >> Basically, I want to spawn a goroutine per ob

[go-nuts] concurrent write-only to map ok?

2017-10-13 Thread Alex Buchanan
Basically, I want to spawn a goroutine per object, objects have unique IDs, and I want each routine to write its results to a shared map. Nothing will be reading from the map while the goroutines are running. Is this safe? Thanks -- You received this message because you are subscribed to the

[go-nuts] Re: Building a neural net from scratch

2017-10-11 Thread Alex Buchanan
I just happen to have read your "Common Go for Data Science Questions" post this morning and loved it. Looking forward to reading the rest of your stuff. Keep up the great work. I'm writing Go for infrastructure in an environment (computational biology) surrounded by data scientists writing pyt

[go-nuts] Re: What is the best way to represent functional options within factory methods?

2017-10-11 Thread Alex Buchanan
I'm not sure I understand the example, but have you seen the grpc library's use of options? For more type safety, you could define an interface such as type PluginOpt interface { pluginOpt() }. https://godoc.org/google.golang.org/grpc#CallOption On Wednesday, October 11, 2017 at 11:23:16 AM UTC

[go-nuts] Task scheduler as a library?

2017-10-11 Thread Alex Buchanan
Hey all, In Funnel (a distributed task toolkit) we're sort of dancing around having a full-on scheduler. We have a scheduler that has grown from development util, to prototype, to something we actually use, but it's missing many of the features you'd want in production. Mostly we aim to delegat

[go-nuts] [ANN] roger, an app configuration library experiment

2017-10-08 Thread Alex Buchanan
My weekend project for that past couple weeks has been roger: https://github.com/buchanae/roger This is another take on application configuration management: flags, env vars, YAML, etc. The core ideas are: - define config as structs - defaults are defined by functions which return instances of

Re: [go-nuts] os/exec stdout bytes.Buffer and timeout behavior?

2017-09-29 Thread Alex Buchanan
exit? Not pretty, but might work. My best approach so far is to use time.After and panic, instead of context. This code is being used in a test, so panic is somewhat acceptable. Thanks again. On 9/29/17, 1:26 PM, "Ian Lance Taylor" wrote: >On Fri, Sep 29, 2017 at 12:33 PM,

[go-nuts] os/exec stdout bytes.Buffer and timeout behavior?

2017-09-29 Thread Alex Buchanan
package main import ( "bytes" "context" "log" "os/exec" "time" ) func main() { var stdout bytes.Buffer ctx, cancel := context.WithTimeout(context.Background(), time.Second) defer cancel() cmd := exec.CommandContext(ctx, "/bin/sh", "-c", "sleep 10; echo foo") cmd.Stdout = &st

[go-nuts] Docs for vendored packages?

2017-09-25 Thread Alex Buchanan
Does anyone have a strategy for accessing the docs (godoc) of vendored dependencies? I was a little surprised to find that godoc decided not to show vendored packages, here: https://github.com/golang/go/issues/13929 This also applies more generally than vendored deps. In the past, I have found