[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

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] 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] 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] 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: 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] 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] 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: 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] 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] 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] 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
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: 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] 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] 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
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
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] 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] 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..".

[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=""

Re: [go-nuts] Question about net/http package implementation

2017-02-18 Thread Dan Kortschak
On Fri, 2017-02-17 at 22:59 -0800, vova...@gmail.com wrote: > I'm wondering, if there's any benefit of writing* r2 := new(Request); > *r2 = *r *rather than shorter *r2 := *r (example below) *or this is > just matter of style preference? *r2 := *r is not legal.

Re: [go-nuts] Question about net/http package implementation

2017-02-20 Thread Dan Kortschak
Yep. I was lazy though - I should have read the example and I could have made a more careful parse of the text to see a lone *or" that might have prompted further investigation. Historical note: /, * and _ were used in text only mail and on usenet prior to html markup contaminating email.

Re: [go-nuts] Question about net/http package implementation

2017-02-19 Thread Dan Kortschak
On Sat, 2017-02-18 at 23:15 +, Matt Harden wrote: > They didn't say ; they said r2 := *r. Also read the example. > They > returned instead of r2. The code is equivalent to but shorter > than the > original. After I read the example I realised that. However the text shows up on a text-only

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

Re: [go-nuts] Why is Go Unicode concat so slow compared to Python3 ?

2017-02-27 Thread Dan Kortschak
When the python functions are actually called the comparison is more reasonable: ``` ~/concat $ go test -bench . concat_test.go  BenchmarkUnicodeConcat-8      20 10379 ns/op PASS ok  command-line-arguments 2.193s ~/concat $ python concat_test.py  time_taken = 8901.3030529

Re: [go-nuts] Goroutine in a for loop: Closure versus direct

2017-02-26 Thread Dan Kortschak
On Sat, 2017-02-25 at 09:03 +, Jan Mercl wrote: > They're not, #2 has a data race. There is no race, the go routine is not a closure. -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receiving emails

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

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

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

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

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

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'

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

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

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

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

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

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,

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

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  >

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

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

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] 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{}

Re: [go-nuts] Why were tabs chosen for indentation?

2017-03-20 Thread Dan Kortschak
On Mon, 2017-03-20 at 09:45 +0100, 'Axel Wagner' via golang-nuts wrote: > The "philosophy of gofmt" was to end arguments about how go code > should be formatted. > Which gives this thread a special form of irony :) People will always adjust their behaviour to minimise the delta on their

Re: [go-nuts] How do I test an func which depends on (pseudo)-random numbers, e.g. rand.Intn()?

2017-03-14 Thread Dan Kortschak
If you let randSpaceline take a *rand.Rand then you can control the source of the randomness and arbitrarily set the seed. You also get the advantage of having a non-mutex protected rand source if you don't need it (we do a similar thing and used rand. if the *rand.Rand is nil as a convenience).

Re: [go-nuts] Is it harmful to always return invalid values on a non-nil-error?

2017-04-04 Thread Dan Kortschak
There are cases in the standard library that explicitly intentionally return, or leave, invalid values in cases when they should not be used. This being the generalised case of this question. One of the clearest examples (others don't necessarily have comments) of this is in go/types/initorder.go

Re: [go-nuts] Is it harmful to always return invalid values on a non-nil-error?

2017-04-04 Thread Dan Kortschak
On Tue, 2017-04-04 at 18:41 -0700, utyughj...@mail.com wrote: > case in point: https://play.golang.org/p/p7WtbMZj3O Why would you return a newly allocated [c]byte pointer in fooSTUPID instead of nil? That is *not* doing what is suggested, but rather returning a more likely valid and usable

Re: [go-nuts] Recover considered harmful

2017-04-24 Thread Dan Kortschak
We (gonum) would extend the security exception to include scientific code; there are far too many peer reviewed works that depend on code that will blithely continue after an error condition that should stop execution or log failure. These can and do end up contributing to costs of

Re: [go-nuts] Re: Generics are overrated.

2017-08-01 Thread Dan Kortschak
On Tue, 2017-08-01 at 09:21 +0200, Sebastien Binet wrote: > the other place I had (very recently) felt they could have been > useful: >  - having a mat.Dense of math/big.Rat (in lieu of a mat.Dense of > float64) I think that would be very hard. The reasons behind this claim are that there is lot

Re: [go-nuts] Re: Go one-line installer

2017-08-01 Thread Dan Kortschak
Thanks. On Tue, 2017-08-01 at 19:14 -0700, Steve Francia wrote: > > On Tuesday, August 1, 2017 at 7:49:32 PM UTC-4, Florin Pățan wrote: > > > > > > Hi, > > > > The idea is good but: > > - it needs to modify the path to add GOROOT/bin and GOPATH/bin to > > it > > > It does. If it didn't do

[go-nuts] cgo related error assigning from a ((size_T)(-1)) define

2017-08-10 Thread Dan Kortschak
I'm pretty sure this should never have worked, but it seemed to previously and now it doesn't. In the gonum/hdf5 package there is a var declared against an HDF5 define like so, `var h5t_VARIABLE int64 = C.H5T_VARIABLE`[1]. `H5T_VARIABLE` is defined in H5Tpublic.h as `#define H5T_VARIABLE

Re: [go-nuts] cgo related error assigning from a ((size_T)(-1)) define

2017-08-10 Thread Dan Kortschak
Yeah, that doesn't work. Returning the value from the C.func does though. The whole system is pretty queasy-making. (Looking at the internal behaviour of SetSize, it should probably not take a uint64, since it expects a -1 sentinel for variable length). On Thu, 2017-08-10 at 12:00 +0100, roger

Re: [go-nuts] Is there a more efficient way to slice a multidimensional matrix using proxy?

2017-08-12 Thread Dan Kortschak
The cap fields allow us to resize back to the original size (just the same as a cap in a Go slice). This is not necessary for any case where only slicing to a smaller size is needed. The allocation that we do in making a new *Dense would not be needed if the mat.Matrix returned did not modify its

Re: [go-nuts] Is there a more efficient way to slice a multidimensional matrix using proxy?

2017-08-12 Thread Dan Kortschak
We implement this for first and second order tensors in gonum.org/v1/gonum/mat[1], which you are welcome to borrow from to extend to third order. Our slice operation[2] is in principle non- allocating (though we do allocate a container for generality - a non- allocating version would simply not

Re: [go-nuts] Re: Named or unnamed struct initialisation? What is best practice?

2017-07-16 Thread Dan Kortschak
Both are used. On Wed, 2017-07-12 at 11:43 +, Matthew Zimmerman wrote: > Why not use struct{}?  Is what is recommended for maps to notate a > set > (only the keys mean something). -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To

Re: [go-nuts] Re: Named or unnamed struct initialisation? What is best practice?

2017-07-16 Thread Dan Kortschak
Yes, trailing zero-size elements affect the size. https://play.golang.org/p/Ox0FJX3C5V https://github.com/golang/go/commit/6f07ac2f280847ee0346b871b23cab90869f84a4 On Tue, 2017-07-11 at 20:34 -0700, Rader wrote: > I found the position of `[0]byte` in the struct matters.  >  type bar2 struct { >

[go-nuts] unexpected strconv.FormatFloat behaviour

2017-07-01 Thread Dan Kortschak
Is this expected: ``` package main import ( "fmt" "strconv" ) func main() { fmt.Print(strconv.FormatFloat(0.5, 'f', 0, 64)) } ``` ``` 0 ``` https://play.golang.org/p/HEyxpGPrX3 This is truncating, not rounding. -- You received this message because you are subscribed

Re: [go-nuts] unexpected strconv.FormatFloat behaviour

2017-07-02 Thread Dan Kortschak
Thanks Rémy. Welcome back. On Sun, 2017-07-02 at 09:04 +0200, Rémy Oudompheng wrote: > 2017-07-02 6:20 GMT+02:00 Dan Kortschak <dan.kortsc...@adelaide.edu.a > u>: > > > > Is this expected: > > > > ``` > > package main > > >

Re: [go-nuts] Re: Named or unnamed struct initialisation? What is best practice?

2017-07-05 Thread Dan Kortschak
On Wed, 2017-07-05 at 17:26 -0700, rsr via golang-nuts wrote: > type bar struct { >    A int >    _ bool > } or `type bar struct { A int; _ [0]byte }` to avoid the additional byte use. -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To

Re: [go-nuts] [Go2] Reflect

2017-08-05 Thread Dan Kortschak
On Sat, 2017-08-05 at 09:58 -0700, Gert wrote: > Reflect should be a generic way of Go2, but everytime i need to > reflect  > around a Go1 interface i want to go on a vacation... Then the API is working! -- You received this message because you are subscribed to the Google Groups "golang-nuts"

Re: [go-nuts] Can warnings of race detector be ignored and toleranted?

2017-08-08 Thread Dan Kortschak
No. https://software.intel.com/en-us/blogs/2013/01/06/benign-data-races-wha t-could-possibly-go-wrong On Tue, 2017-08-08 at 19:52 -0700, Cholerae Hu wrote: > Some of my colleagues think that, in some cases, such as > approximately  > counting the sum total of requests, we don't need to know the

Re: [go-nuts] Re: Generics are overrated.

2017-07-31 Thread Dan Kortschak
We use sets in the graph packages, but the number of set types is pretty limited (sets of nodes and sets of either int or int64) and map[T] works for that level of use. The only other place where it might be useful for us is in in place of generating float32 versions of float64 blas and lapack

Re: [go-nuts] Re: No Allman-Style, No go!

2017-07-27 Thread Dan Kortschak
Lovely post, Michael, as usual. http://photobucket.com/gallery/user/Clayskater/media/bWVkaWFJZDoxNzA1MjQzMDM=/ I ran out of pop-corn for this thread some years ago. Does anyone know where I can get some more? It must be butter soaked, cooked over coals and served in a silver tureen, otherwise I

Re: [go-nuts] Re: [Go2] Reflect

2017-08-06 Thread Dan Kortschak
>From the Laws of Reflection[1]: > It's a powerful tool that should be used with care and avoided unless > strictly necessary.  The reflect package is not mentioned in the spec (except once to discuss struct tags), adding a built-in would require its definition there, and complicate the

Re: [go-nuts] Calling Julia from Go

2017-08-17 Thread Dan Kortschak
What is it that you want to do in Julia? On Wed, 2017-08-16 at 23:57 -0700, mrech...@gmail.com wrote: > I would like to implement a valuation server. For the whole server  > infrastructure I would like to use Go, because it feels more natural > than  > any other language for it. For the

Re: [go-nuts] check for *string that is nil

2017-08-22 Thread Dan Kortschak
Is there a reason to have the fields be *string rather than just string? On Tue, 2017-08-22 at 15:48 -0700, Eric Brown wrote: > Let's say I have a struct... > > type Contact struct { >  Id    int `json:"id"` >  FirstName *string `json:"firstname"` >  LastName  *string `json:"lastname"` >

[go-nuts] fun: Gödel Escher Bach typogenetics game implemented in Go

2017-06-20 Thread Dan Kortschak
This is the bare bones implementation to allow playing with the game. Unstated assumptions from the book are not guessed at and the system is fairly broadly configurable. https://github.com/kortschak/typo -- You received this message because you are subscribed to the Google Groups

Re: [go-nuts] present tool running snippet on native client: "Native Client nameservice: not implemented on Native Client"

2017-05-30 Thread Dan Kortschak
It looks like the go version hits this. Updating to a more recent go install fixes the problem (the previous was go1.3.1). On Tue, 2017-05-30 at 15:38 +0930, Dan Kortschak wrote: > I have just updated (after some years) a server I use for presenting > course material to NaCl pepper_49 (prev

[go-nuts] present tool running snippet on native client: "Native Client nameservice: not implemented on Native Client"

2017-05-30 Thread Dan Kortschak
I have just updated (after some years) a server I use for presenting course material to NaCl pepper_49 (previously pepper_39). The runnable examples I have work, however stderr is contaminated with the string "Native Client nameservice: not implemented on Native Client". The documentation for

Re: [go-nuts] Go For Data analysts

2017-06-02 Thread Dan Kortschak
On Thu, 2017-06-01 at 23:31 -0700, Vikram Rawat wrote: > Does anybody actually uses GO for data Analysis... Yes, they do. https://github.com/gophercon/2016-talks/tree/master/DanielWhitenack-GoForDataScience https://www.youtube.com/watch?v=D5tDubyXLrQ > Can it be used for Data analysis Yes, it

Re: [go-nuts] Re: Go 1.8.1 is released

2017-05-08 Thread Dan Kortschak
Is github not visible from there? If it is, clone the repos from github to the expected locations for $GOPATH and $GOROOT. On Mon, 2017-05-08 at 19:39 +0500, Micky wrote: > It's just politics! > > Simply use a VPN, Tor or a proxy to bypass the filter! -- You received this message because you

Re: [go-nuts] internal/poll.runtime_pollWait problem on RHEL with 3.10.0-327.el7.x86_64

2017-10-02 Thread Dan Kortschak
``` On Fri, 2017-09-29 at 06:52 -0700, Ian Lance Taylor wrote: > On Thu, Sep 28, 2017 at 10:12 PM, Dan Kortschak > <dan.kortsc...@adelaide.edu.au> wrote: > > > > > > I have just tried replicating the issue today and this time, one > > machine passes everyt

Re: [go-nuts] internal/poll.runtime_pollWait problem on RHEL with 3.10.0-327.el7.x86_64

2017-10-02 Thread Dan Kortschak
Agreed. I think there is a deep problem, but the deep problem is here rather than in the Go tests. thanks Dan On Mon, 2017-10-02 at 18:16 -0700, Ian Lance Taylor wrote: > 10 minutes is the default timeout, so that's why that run failed. > > 5 minutes, the time shown above, is an extraordinarily

  1   2   3   4   5   6   7   >