Re: [go-nuts] Re: type assertion: Can I DRY this up?

2016-11-01 Thread Dan Kortschak
https://github.com/jmoiron/jsonq ? On Tue, 2016-11-01 at 10:13 -0700, wwar...@gmail.com wrote: > Basically, the idea is: given a json structure, and a list of strings > or  > integers, treat the list as a path into the structure and return the > value  > at that point. There are some things this

Re: [go-nuts] last day of october AddDate(0,1,0), got fist day of december, not last of november

2016-10-30 Thread Dan Kortschak
Yes, that is described (exactly) in the documentation for AddDate: ``` AddDate normalizes its result in the same way that Date does, so, for example, adding one month to October 31 yields December 1, the normalized form for November 31. ``` On Sun, 2016-10-30 at 20:39 -0700, Mican Zhang wrote: >

Re: [go-nuts] mgo , slice , reset var, need help understanding why this works

2016-10-24 Thread Dan Kortschak
I would guess this is because when iter.Next is given a nil bson.M is needs to make a new value to fill (which from your output is a map). When it is handed a bson.M that already has a map in it, it can use that. Remember that bson.M is just interface{} and maps are pointer- like. On Mon,

Re: [go-nuts] incomplete stack trace

2016-10-07 Thread Dan Kortschak
Thanks, Ian. On Fri, 2016-10-07 at 07:05 -0700, Ian Lance Taylor wrote: > > This is a case where the default traceback is letting you down, > because the failing goroutine was started by the os/exec package.  > You > want to set GOTRACEBACK=all to get more useful data. > > Ian -- You received

Re: [go-nuts] incomplete stack trace

2016-10-07 Thread Dan Kortschak
On Fri, 2016-10-07 at 06:00 +, Jan Mercl wrote: > Perhaps the panic occurs in some init() function and/or a TLD variable > initializer? FTR, the panic is here: > https://github.com/golang/go/blob/f75aafdf56dd90eab75cfeac8cf69358f73ba171/src/bytes/buffer.go#L158 > I've figured out the cause of

[go-nuts] incomplete stack trace

2016-10-06 Thread Dan Kortschak
I have just been given the following stack trace for a program I working on. The trace terminates before it gets into my program, making it's utility close to zero. Does anyone have any idea why it is not extending into main? $ go build back.go $ ./back panic: runtime error: invalid memory

Re: [go-nuts] overriding keywords or rather allowing them to be part of a struct in go?

2016-10-04 Thread Dan Kortschak
On Mon, 2016-10-03 at 23:32 -0700, David Luu wrote: > type runKeywordReturnType struct{ > return interface{} > status string > output string > error string > traceback string > } > > Seems to not work since return and error are go keywords. You can't do so with return, but error is not

[go-nuts] unsafe horror: introspecting chans

2016-10-04 Thread Dan Kortschak
I am thinking about adding the capacity to dump the contents of chans to the utter package[1]. The code to do this is relatively straightforward[2], though it messes about with unsafe aliasing of runtime types in nasty ways. One thing that I'm not sure of is the locking that is required (I

Re: [go-nuts] getting method comments from a package

2016-09-27 Thread Dan Kortschak
Thanks. On Tue, 2016-09-27 at 11:35 +0100, roger peppe wrote: > A slightly different problem, but you might be interested > in this code that I use to find the doc comment for a method > that's been discovered through go/types: > > https://play.golang.org/p/POH1FwOCsZ -- You received this

[go-nuts] getting method comments from a package

2016-09-26 Thread Dan Kortschak
Is there a nicer way to do this than what I have here? func MethodDocComments(path string) (map[string]string, error) { fset := token.NewFileSet() pkgs, err := parser.ParseDir(fset, path, nil, parser.ParseComments) if err != nil { return nil, err }

Re: [go-nuts] unix.Poll weirdness

2016-09-15 Thread Dan Kortschak
Thanks for the very clear explanation, Ian. I figured there was something like that. It turns out I was using a fifo badly (I was trying to model a sysfs attribute - clearly incorrectly as I now find out that poll should wait on POLLPRI for sysfs attributes). The original problem is now solved.

[go-nuts] unix.Poll weirdness

2016-09-15 Thread Dan Kortschak
I am in the process of adding sysfs polling support for a physical device and I'm using a small Go program (https://play.golang.org/p/5v8DsGv6Dk) to help test whether what I'm doing is working (it's not yet). In doing this, I've found somethings that I don't understand with the

Re: [go-nuts] Re: Two Related Questions. (1) Map Concurrency (2) Making Multidimensional Arrays

2016-09-12 Thread Dan Kortschak
Another way that you can use (based on a recursive map[string]T - where T is an interface type - can be seen here where I use it create a filesystem of arbitrary behaviours). https://github.com/ev3go/sisyphus The general case though uses map[string]interface{}. Each time you want to add a layer

Re: [go-nuts] Re: Two Related Questions. (1) Map Concurrency (2) Making Multidimensional Arrays

2016-09-12 Thread Dan Kortschak
On Mon, 2016-09-12 at 20:26 -0700, davidmiller...@gmail.com wrote: > Well, PHP is also free. It can do multidimensional associative arrays > and much more. What good is Golang's tremendous efficiency if it isn't > capable of doing what is needed in the first place? Depends on how much work you

Re: [go-nuts] Re: Two Related Questions. (1) Map Concurrency (2) Making Multidimensional Arrays

2016-09-12 Thread Dan Kortschak
On Mon, 2016-09-12 at 20:06 -0700, davidmiller...@gmail.com wrote: > If I understand that correctly, my index key is now "Folder_1 > Folder_2 > Folder_3 Folder_4" and my value is now "File_Name_1". How would I now > assign "File_Name_2" to Folder_2, for example? The key would be

Re: [go-nuts] Re: Two Related Questions. (1) Map Concurrency (2) Making Multidimensional Arrays

2016-09-12 Thread Dan Kortschak
https://play.golang.org/p/6ZyybAKWpp On Mon, 2016-09-12 at 18:50 -0700, davidmiller...@gmail.com wrote: > I tried that. I can't seem to get it to work. I'm clearly doing > something > wrong, probably because I am misunderstanding Tamás's response. > > Test_Map := make(map[[4]string]string) >

Re: [go-nuts] Nil interface/pointer

2016-09-11 Thread Dan Kortschak
On Sun, 2016-09-11 at 19:41 +1000, Kiki Sugiaman wrote: > Not exactly a solution for the faint hearted, hah! It's long, but not complicated, and in the context of Axel's comment would be placed in a helper of some variety. For those at home, it's necessary to take the address of the interface

Re: [go-nuts] Nil interface/pointer

2016-09-10 Thread Dan Kortschak
On Sun, 2016-09-11 at 03:02 +1000, Kiki Sugiaman wrote: > If I know every possible type (that implements the interface), I can > do > a type switch. But if I don't, there's no way to do this then? reflect will help here: https://play.golang.org/p/h76XV_eTJx -- You received this message

Re: [go-nuts] Re: In case you missed it: language benchmarks for Go 1.7, and language adoption

2016-09-09 Thread Dan Kortschak
Can you explain the rationale behind the classification of libraries as libraries or not libraries? It seems pretty arbitrary. (I'm interested from a sociological perspective, but not enough to bother to go to the benchmarks game discussion forum). On Fri, 2016-09-09 at 15:08 -0700, 'Isaac Gouy'

Re: [go-nuts] Is SizedReaderAt coming back in 1.8?

2016-09-09 Thread Dan Kortschak
The problem is that some Size methods return (int64, error) and others return int64, so the interface was removed, since it can't match all the types in the stdlib that it might be useful for. You can easily define it yourself for your own use though, and provide a shim for the types that don't

Re: [go-nuts] Pointer literal

2016-09-07 Thread Dan Kortschak
On Wed, 2016-09-07 at 08:42 -0700, 'Mihai B' via golang-nuts wrote: > Any HTTP API with PATCH support needs to use pointers on basic types. > Therefore I'm wondering if there is any will/proposal to make pointer > initialisation easier to work with basic types. The `standard` way is > quite >

Re: [go-nuts] help with bazil.org/fuse

2016-09-07 Thread Dan Kortschak
Thank you so much, Julian. That makes everything clear. On Wed, 2016-09-07 at 19:02 +0100, Julian Phillips wrote: > Not here. The resulting file is 31 bytes, with 19 leading NULs. You > won't see the NULs if you just cat the file though. -- You received this message because you are

Re: [go-nuts] help with bazil.org/fuse

2016-09-06 Thread Dan Kortschak
On Tue, 2016-09-06 at 19:54 +0200, Lars Seipel wrote: > These are just the flags passed to open. If you want to act on the > truncate flag, do it once within open, not on every single subsequent > call to write. > That makes sense. So, we're narrowing down on my field of ignorance. Am I right in

Re: [go-nuts] help with bazil.org/fuse

2016-09-04 Thread Dan Kortschak
I have found some errors (not properly communicating size changes in the Setattr response), but these do not fix the problem. The Setattr method is now // Setattr satisfies the bazil.org/fuse/fs.NodeSetattrer interface. func (f *RW) Setattr(ctx context.Context, req *fuse.SetattrRequest, resp

[go-nuts] help with bazil.org/fuse

2016-09-04 Thread Dan Kortschak
Can someone tell me what it is that I'm failing to understand with file truncation/write and FUSE? The issue is demonstrated here with this code (exerted from [1] in sisyphus_test.go): f, err := os.OpenFile(fusemountedfilename, os.O_RDWR|os.O_CREATE, 0666) if err != nil {

Re: [go-nuts] Re: Why can't convert []T to []T2 if T2 is a copy definition of T?

2016-09-04 Thread Dan Kortschak
On Fri, 2016-09-02 at 13:47 -0700, nicolas riesch wrote: > In your original example, if you don't cast, it works. > > https://play.golang.org/p/g-GScYkA5S That is not doing what the OP wanted though; they wanted a []int. https://play.golang.org/p/YpyYXIu9D2 > The explanation is here: > >

Re: [go-nuts] unsupported GOOS/GOARCH pair darwin/x86_64 on mac installed from package

2016-08-31 Thread Dan Kortschak
On Wed, 2016-08-31 at 17:37 -0700, Ian Lance Taylor wrote: > Set GOARCH in the environment to amd64, not x86_64. Or don't bother > to set it at all. > Thanks Ian. Just went through and clean out many GO* vars from his .profile. -- You received this message because you are subscribed to the

[go-nuts] unsupported GOOS/GOARCH pair darwin/x86_64 on mac installed from package

2016-08-31 Thread Dan Kortschak
One of my users has struck a problem with an install of go1.7 from the packages at [1] that has me baffled. I don't use a mac, so I've depleted my knowledge of what might be going on here. Can anyone help? thanks Dan The OS is 10.11.6 on a macbook. $ go run hello.go cmd/go: unsupported

Re: [go-nuts] Re: Why can't convert []T to []T2 if T2 is a copy definition of T?

2016-08-28 Thread Dan Kortschak
It seems to me that this comes up often enough that it satisfies the definition of a FAQ. I know that https://golang.org/doc/faq#convert_slice_of_interface is commonly pointed to as an explanation, but it is not entirely satisfactory since it is talking about the specific case of []T to

Re: [go-nuts] Re: Why can't convert []T to []T2 if T2 is a copy definition of T?

2016-08-28 Thread Dan Kortschak
n of Go and instead require explicit casts (as in “var a int = 3; > b := float64(a)”), why they treat Types as non-mixing species, and why > the affordances around this are very limited. > > > > I gave a talk in Madrid about Go as a software engineering approach > assisted b

Re: [go-nuts] Re: Why a **T value can't call methods of *T and T if a *T value can call methods of T?

2016-08-23 Thread Dan Kortschak
It's the answer to the question you have below. On Mon, 2016-08-22 at 23:02 -0700, T L wrote: > On Tuesday, August 23, 2016 at 1:35:16 PM UTC+8, kortschak wrote: > > > > Ian has an answer for this here > > https://groups.google.com/d/msg/golang-nuts/qf76N-uDcHA/DTCDNgaF_p4J > > > the two

Re: [go-nuts] Go 1.7 is released

2016-08-17 Thread Dan Kortschak
"Trust, but verify"? No, that's been used and it didn't turn out so well. On Wed, 2016-08-17 at 08:10 +, Michael Banzon wrote: > "No test, no trust"? -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop

Re: [go-nuts] Simple test runner

2016-08-12 Thread Dan Kortschak
go test ./... On Thu, 2016-08-11 at 23:22 -0700, Simon Ritchie wrote: > Is there a simple tool that will search for and run all the tests in a Go > project? > > What I'm looking for is a tool that will start at a given directory and > descend recursively through any subdirectories, looking

Re: [go-nuts] compressing long list of short strings

2016-08-10 Thread Dan Kortschak
This looks like something that is solved for genomics data. If you are OK with decompressing m strings where m << n then the BGZF addition to gzip would work for you. In brief, BGZF blocks gzip into 64kb chunks which can be indexed. The spec for BGZF is here [1] (section 4 from page 11 on) and

Re: [go-nuts] Re: Best practice for sets in go?

2016-07-26 Thread Dan Kortschak
Very much agree, but also something that has not been explicitly (or at least deeply) said here is the use of a tiny type (when the number of uses warrants - this is salt to taste). type set map[T]struct{} func (s set) has(v T) bool { _, ok := s[v] return ok } func (s set) add(v

Re: [go-nuts] Go is for everyone

2016-07-19 Thread Dan Kortschak
It's an interesting post and something I can see being true to an extent, but I'd like to put forward an alternative from my own experience. I came to Go as an extremely inexperienced programmer - a couple of years with Perl and a childhood with C64 basic/6502/Z80 and virtually no formal CS

Re: [go-nuts] Re: Strange results from append

2016-07-17 Thread Dan Kortschak
On Sun, 2016-07-17 at 09:09 -0700, Evan Digby wrote: > For now the solution is to explicitly make copies, which was the desired > result in the first place. > > The code I posted earlier works as desired. You don't need to make explicit copies. If you use three index slicing, you get the

Re: [go-nuts] Re: why treat int and []int differently here?

2016-07-16 Thread Dan Kortschak
On Sat, 2016-07-16 at 15:36 -0700, pi wrote: > `type` is not `typedef` in Go. `type` introduces completely new type. > Fortunately, Go can cast these types to base type silently, i.e. > explicict > cast int(valueOfTI) is unnecessary. This is not true; a named concrete type is never silently

Re: [go-nuts] Re: Golang concurrency design question

2016-07-14 Thread Dan Kortschak
On Wed, 2016-07-13 at 23:13 -0700, Richard Todd wrote: > I don't think there is a right answer here, without a context. > Yeah. The net package is instructive here. There are cases where a goroutine is spawned with the acquireThread call (this blocks on a chan operation to limit thread use) just

Re: [go-nuts] Proposal: Add coloured output to go commands

2016-07-12 Thread Dan Kortschak
github.com/maruel/panicparse is a good package to do this if you need it. On Tue, 2016-07-12 at 22:26 -0700, Ian Lance Taylor wrote: > On Tue, Jul 12, 2016 at 9:36 PM, Zac Pullar-Strecker wrote: > > Commands like go run, go build and go test amoung others should have > >

Re: [go-nuts] Re: Can I convert bytes.Buffer object to a string, and vice-versa ?

2016-07-11 Thread Dan Kortschak
I think a key word in the question is "original". Depending on how that is intended the answer is either "no" (unless unsafe is used with a whole heap of rigmarole) or "yes" with something along the lines of the playground link here (though note that bytes.Buffer has a String() string method). On

Re: [go-nuts] Re: Hi, someone may help me converting this python code to GO

2016-07-10 Thread Dan Kortschak
It's worth returning the error from strconv.ParseUint in the general case. On Sun, 2016-07-10 at 21:02 -0700, eavi...@gmail.com wrote: > Thanks every one > > finally did it > > https://play.golang.org/p/20KzDE_u2a > -- You received this message because you are subscribed to the Google

Re: [go-nuts] Re: Hi, someone may help me converting this python code to GO

2016-07-10 Thread Dan Kortschak
On Sun, 2016-07-10 at 15:34 -0700, eavi...@gmail.com wrote: > 1) it not return exactly what return the code in python The code I have on the playground gives the same return as your python code. -- You received this message because you are subscribed to the Google Groups "golang-nuts" group.

Re: [go-nuts] Re: Hi, someone may help me converting this python code to GO

2016-07-10 Thread Dan Kortschak
Not here. On Sun, 2016-07-10 at 10:04 +0100, Michael Jones wrote: > I get “030a1x” as the result of my Go port. Is that what you expected? -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receiving emails

Re: [go-nuts] golang time.Duration calculation

2016-07-06 Thread Dan Kortschak
Type convert *prior* to the division. https://play.golang.org/p/7cwTFu_3im On Wed, 2016-07-06 at 15:01 -0700, Tong Sun wrote: > To make the point, let's use *68 seconds*, > > https://play.golang.org/p/mfuJQa3_65 > > I need the result to be 52.94, instead of 52. -- You received this

Re: [go-nuts] Matrix Library && colour uint32's vs uint8's

2016-07-03 Thread Dan Kortschak
They're packages, not links. https://github.com/gonum/matrix - docs: https://godoc.org/github.com/gonum/matrix/mat64 https://github.com/go-gl/mathgl - docs: https://godoc.org/github.com/go-gl/mathgl/mgl64 On Mon, 2016-07-04 at 12:08 +1000, simran wrote: > Hi Dan, > > I get a "page not found"

Re: [go-nuts] Matrix Library && colour uint32's vs uint8's

2016-07-03 Thread Dan Kortschak
github.com/gonum/matrix/mat64 (soonish to be gonum.org/pkg/matrix/mat64) is a general purpose matrix library. A more specific image maths package is available at github.com/go-gl/mathgl/mgl{32,64}. On Mon, 2016-07-04 at 10:07 +1000, simran wrote: > Hi Dan, > > I am hoping to find a general

Re: [go-nuts] Matrix Library && colour uint32's vs uint8's

2016-07-03 Thread Dan Kortschak
Are you looking for generalised matrices or simply image rotation/translation/transformation? On Mon, 2016-07-04 at 02:06 +1000, simran wrote: > > Could someone please point me to a good matrix library for Go (i'm > sure > something exists, although i can't seem to find it!). > > Am hoping to

Re: [go-nuts] Matrix Library && colour uint32's vs uint8's

2016-07-03 Thread Dan Kortschak
Are you looking for generalised matrices or simply image rotation/translation? On Mon, 2016-07-04 at 02:06 +1000, simran wrote: > > Could someone please point me to a good matrix library for Go (i'm > sure > something exists, although i can't seem to find it!). > > Am hoping to do some image

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

2016-06-30 Thread Dan Kortschak
This position precludes the following use of the equality operator for scalar values: a := 1 b := 1 a == b would be false under the approach below since a and b are not the same set of bits. I think most people would find this a little surprising. On Thu, 2016-06-30 at 09:24 -0700, Chad wrote:

[go-nuts] Re: curious problem implementing RGB565 image

2016-06-13 Thread Dan Kortschak
e high byte. thanks On Tue, 2016-06-14 at 11:15 +1000, Nigel Tao wrote: > On Mon, Jun 13, 2016 at 9:10 PM, Dan Kortschak > <dan.kortsc...@adelaide.edu.au> wrote: > > Though doing the direct round trip of an image through an RGB565 gets > > back the pixels in a state tha

<    2   3   4   5   6   7