Re: [go-nuts] go executable cross-compiled for arm5 works on amd64 (and arm5)

2017-02-16 Thread Dan Kortschak
Thank you. Yes, I had forgotten I'd installed that (needed for kernel building for the very same arm5 device). Dan On Thu, 2017-02-16 at 21:31 +1300, Michael Hudson-Doyle wrote: > Do you have qemu-user-static or a similarly named package installed? > Then > the magic of binfmt_misc may be invokin

[go-nuts] go executable cross-compiled for arm5 works on amd64 (and arm5)

2017-02-15 Thread Dan Kortschak
Can someone explain to me why this works? I am cross-compiling for arm5, but the executable works on amd64. $ cat hello.go  package main import "fmt" func main() { fmt.Println("hello") } $ GOARCH=arm GOARM=5 go build hello.go  $ ./hello  hello $ go env GOARCH="amd64" GOBIN="" GOEXE="" GO

Re: [go-nuts] json: cannot unmarshal array into Go value of type main error

2017-02-02 Thread Dan Kortschak
You have handed json.Unmarshal a non-slice/non-array type. Try this https://play.golang.org/p/Zl5G_Rkt26 On Thu, 2017-02-02 at 15:15 -0800, Rejoy wrote: > I 'd like to unmarshal database records into a struct type. I get the > error "json:  > cannot unmarshal array into Go value of type main..".

Re: [go-nuts] exec.Command("cp", "-r", "./*.json", artifact.dir fails with exit status 1

2017-01-16 Thread Dan Kortschak
Before answering the questions below, you should know that exec.Command will not do shell glob expansion since it does not invoke commands via a shell. If you want to do that you can either invoke via a shell or do the globbing yourself with filepath.Glob[1]. 1. You can capture the combined output

Re: [go-nuts] strange behavior for type switch

2017-01-11 Thread Dan Kortschak
Alternatively, https://godoc.org/github.com/cznic/mathutil which has already typed each of those five line snippets for you. On Thu, 2017-01-12 at 13:45 +1030, Dan Kortschak wrote: > In practice, it's better to implement a min(a, b T) T for each T that > you actually need (it's

Re: [go-nuts] strange behavior for type switch

2017-01-11 Thread Dan Kortschak
Go does not have a notion of casting, and working towards a solution that starts with a need for generics will end in tears. If you want to have a universal numeric -> float64 conversion, this[1] might work, though I really don't think it is a good idea, and won't help in your broader scheme to ma

Re: [go-nuts] strange behavior for type switch

2017-01-11 Thread Dan Kortschak
What are you trying to do? The behaviour of LimRange as you have it here is to return the float64 value of x if it is a float64, zero if it is another numerical type in the case list and NaN if it is none of those. I would suggest you read https://golang.org/ref/spec#Switch_statements  particular

Re: [go-nuts] strange behavior for type switch

2017-01-11 Thread Dan Kortschak
On Wed, 2017-01-11 at 17:15 -0800, hui zhang wrote: >    switch v := x.(type) { >    case int,int8,int16,int32: What type is v here? It can't be any of the four types you have listed in the case since are not assignable to each other without conversion, so it must be an interface{}. interface{} ca

Re: [go-nuts] image Gray16 endianness

2017-01-11 Thread Dan Kortschak
On Wed, 2017-01-11 at 16:46 +1100, Pablo Rozas Larraondo wrote: > Thanks Dan. I'm just surprised that Gray16 uses big endian when, for > example, Go's uint16 type uses the little endian convention. On *most* supported architectures. > I guess I find this weird and I want to know if there is a rea

Re: [go-nuts] image Gray16 endianness

2017-01-10 Thread Dan Kortschak
On Wed, 2017-01-11 at 16:21 +1100, Pablo Rozas Larraondo wrote: > I'm confused with image.Gray16 having pixel values represented in the > wrong order. It seems to me that image.Gray16 considers numbers to be > big endian instead of little endian. Why do you think that is the wrong order? Here is

Re: [go-nuts] Reset Slice with Make Every Time?

2017-01-09 Thread Dan Kortschak
On Mon, 2017-01-09 at 15:12 -0800, Tomi Häsä wrote: > Is this the correct way of resetting a slice? I mean do I always need > to  > use make to reset a slice? > > // initialize slice > > onearea Area = Area{} > > group []Area = make( []Area, 0, MAX ) > > // add stuff to slice >

Re: [go-nuts] RDF "encoding"

2016-11-27 Thread Dan Kortschak
On Sun, 2016-11-27 at 01:46 -0800, Johann Höchtl wrote: > Is there a standard to perform IRIs encoding? Would URL-encoding the > read  > part be acceptable and interoperable? There is a published grammar for RDF, which defines the IRI grammar used. This can be used to write a parser. An example o

Re: [go-nuts] Inevitable unexpected EOF

2016-11-27 Thread Dan Kortschak
I don't see anywhere that you are closing the gzip.Writer. Does doing that fix the problem? On Fri, 2016-11-25 at 05:12 -0800, Connor wrote: > Hi all. > > I'm trying to implement a structure which gzips multiple  > individually-inflatable messages in the same data stream. I've built > an  > examp

Re: [go-nuts] Reaching infinity

2016-11-16 Thread Dan Kortschak
Rename it buzz_lightyear.go On Wed, 2016-11-16 at 13:58 -0800, Nikita Loskutov wrote: > Is anybody know how to increase "infinities count"? -- 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] How to conv [3]int to []int ?

2016-11-11 Thread Dan Kortschak
That's not necessary. https://play.golang.org/p/_iHnithuxz What a[:] does is create a slice header with the address pointing to the zeroth element of a. The code that is generated is exactly the same for both (you can check this with go tool compile -S). On Thu, 2016-11-10 at 23:46 -0800, steve

Re: [go-nuts] How to conv [3]int to []int ?

2016-11-10 Thread Dan Kortschak
They have different layouts in memory. Do you just want to do this: package main import ( "fmt" ) func main() { a := [3]int{1, 2, 3} b := a[:] fmt.Println(b) } https://play.golang.org/p/OBY7g3azBE If so, there's no need for unsafe. If not, what are you trying to

Re: [go-nuts] why "iota"?

2016-11-09 Thread Dan Kortschak
Or yoh-ta (like Yoda, but with s/d/t/) if not in America. On Wed, 2016-11-09 at 09:30 -0500, Marvin Renich wrote: > Iota is pronounced eye-OH-tuh. -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receiving

Re: [go-nuts] Noob question: Pointers to interfaces

2016-11-07 Thread Dan Kortschak
Thank you Michael for that. I have written a small package to help with this kind of uncertainty :) https://play.golang.org/p/vSnG-HGdrU On Mon, 2016-11-07 at 16:08 -0800, Michael Jones wrote: > Not precisely so…Interfaces, and type switches, and related > mechanisms are safe. Their type indeterm

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 d

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

2016-10-31 Thread Dan Kortschak
A type switch will clean that up a fair bit. var val interface{} var ok bool switch m := m.(type) { case m.(map[string]int): val, ok = mt.Mi[mk] case m.(map[string]i nterface{}): val, ok = mt.Mi[mk] case m.(map[string][]int): val, ok = mt.Mi[mk] case m.(map[string][]string

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, 2016-10-

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-06 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 addres

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 expect

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 mess

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

2016-09-26 Thread Dan Kortschak
fn.Doc.List } } } return docs, nil } On Tue, 2016-09-27 at 14:28 +0930, Dan Kortschak wrote: > Yeah, possibly. Is there is way though to get the associated > ast.CommentGroup for a type's methods? -- You received this message because you are subscribed to the Googl

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

2016-09-26 Thread Dan Kortschak
Yeah, possibly. Is there is way though to get the associated ast.CommentGroup for a type's methods? On Mon, 2016-09-26 at 20:59 -0700, Rob Pike wrote: > It might be less disgusting to use text/scanner. > > -rob -- You received this message because you are subscribed to the Google Groups "gola

[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. O

[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 golang.org/x/sys/un

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 a

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 wa

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 []string{"Folder

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 Mon, 2016-09-12 at 01:17 +0100, Julian Phillips wrote: > Um, no you don't ... > > If you want to get at the actual interface type being passed in then > you > need to do the dance, but in this case the question was about the > pointer in the interface - so we don't care about the Fooer type a

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 val

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 because

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

2016-09-10 Thread Dan Kortschak
On Sat, 2016-09-10 at 10:21 -0700, 'Isaac Gouy' via golang-nuts wrote: > No one seems to have needed to discuss what was meant by library, like > sascha they seem to think they understood what was expected. Prior to your earlier post, I thought I did too, but after that many libraries I have used

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-08 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 qu

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 > ve

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 subscribe

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

2016-09-06 Thread Dan Kortschak
On Wed, 2016-09-07 at 09:05 +0930, Dan Kortschak 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 narr

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] Re: help with bazil.org/fuse

2016-09-06 Thread Dan Kortschak
On Tue, 2016-09-06 at 13:19 -0700, Tommi Virtanen wrote: > Err sorry should have read more. Your panic message was > > 2016/09/05 02:57:52 fuse: panic in handler for Write [ID=0x25 > Node=0x8 > Uid=1000 Gid=1000 Pid=3299] 0x2 17 @31 fl=0 lock=0 ffl=OpenReadWrite: > runtime error: slice bounds ou

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 *fu

[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 { log.Fatalf("unex

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: > > http

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 Goog

[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 GOOS/GOA

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
Clarifying: I'm not asking a question. However, the explanation is a good one. It could form the basis for a FAQ answer. On Sun, 2016-08-28 at 22:40 -0700, Ian Lance Taylor wrote: > On Sun, Aug 28, 2016 at 12:41 AM, Dan Kortschak > wrote: > > > > This would have been

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 []interface

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
uring the > design 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 appr

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-22 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 questi

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-22 Thread Dan Kortschak
Ian has an answer for this here https://groups.google.com/d/msg/golang-nuts/qf76N-uDcHA/DTCDNgaF_p4J On Mon, 2016-08-22 at 22:28 -0700, T L wrote: > Looks this question can be stated as "why can't named pointer types > have > methods?" > > package main > > type PT *int > func (pt PT) f() {} //

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 r

Re: [go-nuts] Simple test runner

2016-08-11 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 fo

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 the

Re: [go-nuts] Initialize Variables in case clause of a switch

2016-08-09 Thread Dan Kortschak
On Fri, 2016-08-05 at 08:57 -0700, dc0d wrote: > In Go we can write: > > if _, ok := input.(*data); ok { > //... > } > > Why is it we can't do that in the case clause of a switch statement: > > switch { > case x1,ok:=input.(*data1); ok && otherCond1: > case x2,ok:=input.(*data2); ok && otherCond

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 backgr

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 behavio

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

2016-07-17 Thread Dan Kortschak
Indeed. Thank you. On Sun, 2016-07-17 at 02:03 +0200, Axel Wagner wrote: > Also not true, as OP pointed out ;) A named concrete type is never > silently converted to another *named* concrete type ;) -- You received this message because you are subscribed to the Google Groups "golang-nuts" grou

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 conv

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

2016-07-14 Thread Dan Kortschak
я 2016 г., 9:07:32 UTC+3 пользователь kortschak > написал: > > > > Mostly. As always, the exact context is significant. > > > > On Thu, 2016-07-14 at 15:34 +0930, Dan Kortschak wrote: > > > Yes. This is how it's done in the net package. > > >

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

2016-07-13 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] Re: Golang concurrency design question

2016-07-13 Thread Dan Kortschak
Mostly. As always, the exact context is significant. On Thu, 2016-07-14 at 15:34 +0930, Dan Kortschak wrote: > Yes. This is how it's done in the net package. > > On Wed, 2016-07-13 at 23:01 -0700, sphilip...@gmail.com wrote: > > Block then spawn: https://play.golang.org/p/

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

2016-07-13 Thread Dan Kortschak
Yes. This is how it's done in the net package. On Wed, 2016-07-13 at 23:01 -0700, sphilip...@gmail.com wrote: > Block then spawn: https://play.golang.org/p/fUZ2RKr-u0 -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this grou

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 > > coloured output when an e

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 Group

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. T

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

2016-07-10 Thread Dan Kortschak
You are doing way too much work. Use the features of the language. When you say `fcs, _ := strconv.ParseUint("", base, size)`, why not just `fcs := uint16(0x)`. Make your integer types in Crc16 uint16 since that is what you are working with. On Sun, 2016-07-10 at 15:34 -0700, eavi...@gmai

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 message

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" on

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 matri

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 do

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 man

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

2016-06-30 Thread Dan Kortschak
On Thu, 2016-06-30 at 19:10 -0700, Chad wrote: > I have explained why it was not sufficient upstream. > I don't expect people to create two version of their types, one being > for mere inclusion into maps. > Not really; you've said it's not necessary and you've pointed to map[interface{}]interface

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

2016-06-30 Thread Dan Kortschak
On Thu, 2016-06-30 at 18:48 -0700, Chad wrote: > Again, if you really understand the datastructure and what it > represents, the behaviour is really not surprising. There is no value > "abstraction". CS and software engineering is abstractions all the way down. > > And currently, a comparison pan

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

2016-06-30 Thread Dan Kortschak
On Thu, 2016-06-30 at 18:15 -0700, Chad wrote: > No, it's actually fine. You are comparing values. The issue is that, yes while everything is a value, the value abstraction is tenuous in this context. The result of this tenuous abstraction is that there would be surprising behaviours (already outl

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:

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

2016-06-29 Thread Dan Kortschak
On Wed, 2016-06-29 at 11:19 -0700, Chad wrote: > Just been thinking that since a slice is a "reference" type, why not > allow > slice equality? > Of course the number of cases where two slices are equal would be > quite > low, irrelevant of whether the view they have on their respective > arrays

Re: [go-nuts] Append to slice... what happens?

2016-06-26 Thread Dan Kortschak
On Mon, 2016-06-27 at 07:49 +0200, Martin Geisler wrote: > BTW, I was about to say that you could simplify the line one step > further with > > b := append(a[::len(a)], 3, 4) > > but that gives a compilation error: > > prog.go:11: middle index required in 3-index slice > > I wonder what the

[go-nuts] map memory usage question

2016-06-16 Thread Dan Kortschak
I'm running a terabyte-scale (minor compiler changes are necessary to get this to run) genome resequencing simulation at the moment and an interesting question has arisen. The simulation involved hashing over ~all positions of a genome, either with the key being a string or a [2]string. The dif

[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 > wrote: > > Though doing the direct round trip of an image through an RGB565 gets > > back the pixels in a state that you would expect, shown here in th

[go-nuts] curious problem implementing RGB565 image

2016-06-13 Thread Dan Kortschak
As part of my LEGO robotics project, I'm implementing image handling for various boards' frame buffers (EVB and EV3 in the first instance). Both are working as far as manual testing of rendered images goes, but automated testing has shown up a weird problem. This is best illustrated by looking at

<    2   3   4   5   6   7