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

2017-08-22 Thread Dan Kortschak
OK, then I think you've answered your own question; your uses should handle the nils, rather than papering over them by assigning a pointer to "". If you expect to have "" when the value is empty, just use string. On Tue, 2017-08-22 at 17:39 -0700, Eric Brown wrote: > Yeah, sometimes it's better

Re: [go-nuts] Why does assigning a function variable to a method value allocate memory?

2017-08-27 Thread Dan Kortschak
I've long liked using ragel, but I have to say that with the projects bus factor and recent removal of Go code generation, it's less attractive than it used to be. On Wed, 2017-08-23 at 23:56 -0700, Tamás Gulácsi wrote: > See ragel for an fsm generator! -- You received this message because you a

[go-nuts] expected bahaviour for fmt.Stringer within a container in a struct?

2017-08-30 Thread Dan Kortschak
What is the expected behaviour for this code? https://play.golang.org/p/tp9YNQZRMo ``` package main import ( "fmt" ) type char int func (c char) String() string { return string(c) } type st struct { m map[int]interface{} } func main() { a := char('A') s := st{

Re: [go-nuts] Re: expected bahaviour for fmt.Stringer within a container in a struct?

2017-08-31 Thread Dan Kortschak
Well that's dumb of me - too busy thinking about other details and forgetting the language I was speaking. Thanks. On Thu, 2017-08-31 at 01:24 -0700, moehrmann via golang-nuts wrote: > m is an unexported Field. fmt can not use interface() on the reflect > values  > to then call String on them on a

Re: [go-nuts] How to remove a struct value from a struct slice without memory leak?

2017-09-25 Thread Dan Kortschak
This is not nice if you want to reuse the slice, and still may leak the fields. clients[i] = clients[len(clients)-1] // If the current clients[i] is deleted it becomes inaccessible // and the ipAddr, name and conn fields potentially leak, so // zero them in the last position of the slice. clients[

Re: [go-nuts] How to remove a struct value from a struct slice without memory leak?

2017-09-25 Thread Dan Kortschak
Just to clarify, this is from context discussing Aaron's code. On Mon, 2017-09-25 at 17:38 -0700, 'Keith Randall' via golang-nuts wrote: > I see a couple of issues with your code. >  > On Monday, September 25, 2017 at 5:14:22 PM UTC-7, kortschak wrote: > >  -- You received this message because y

Re: [go-nuts] Re: Graphing libraries in golang

2017-09-27 Thread Dan Kortschak
On Wed, 2017-09-27 at 08:54 -0700, Volker Dobler wrote: > One from https://awesome-go.com/#science-and-data-analysis > probably should fit your needs. Or try looking for R bindings and > run your plots through R. https://godoc.org/gonum.org/v1/plot for the first and https://godoc.org/github.com/

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

2017-09-27 Thread Dan Kortschak
I am seeing all.bash fail when testing cmd/go with a likely cause being internal/poll.runtime_pollWait. I'm trying to build go1.9 (with a change to the heap size), but all.bash fails as shown below. Is this a known problem? and if it is, is there a workaround. thanks ``` panic: test timed out af

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

2017-09-28 Thread Dan Kortschak
17 at 10:20 PM, Dan Kortschak > wrote: > > > > > > I am seeing all.bash fail when testing cmd/go with a likely cause > > being > > internal/poll.runtime_pollWait. > > > > I'm trying to build go1.9 (with a change to the heap size), but > > a

Re: [go-nuts] Needing some explanation of a compile time error

2017-09-28 Thread Dan Kortschak
StringChan and StringSendingChan are named types and so you will need a conversion. It would be easier though to just not declare types here. You don't need them. https://play.golang.org/p/0dBHgsaP0v On Thu, 2017-09-28 at 17:19 -0700, lmumar wrote: > Hi all, > > Good day to you all. I just recen

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

2017-09-28 Thread Dan Kortschak
`` On Thu, 2017-09-28 at 21:23 -0700, Ian Lance Taylor wrote: > On Thu, Sep 28, 2017 at 5:40 PM, Dan Kortschak > wrote: > > > > > > I can replicate this on another newer RHEL machine. In both cases > > the > > machines are quiet (they are the head nodes of HP

Re: [go-nuts] Re: Graphing libraries in golang

2017-09-29 Thread Dan Kortschak
To get bitbucket.org/zombiezen/gopdf/... to install, you will need to install mercurial. On Thu, 2017-09-28 at 23:49 -0700, Vikram Rawat wrote: > Thanks for your reply. Library seems promising. but when I run it , > this  > errors out > > > > cannot find package "bitbucket.org/zombiezen/gopd

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 > wrote: > > > > > > I have just tried replicating the issue today and this time, one > > machine passes everything, while the other does not. I am beg

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

Re: [go-nuts] A few go 2 suggestions

2017-10-10 Thread Dan Kortschak
On Tue, 2017-10-10 at 06:13 -0700, Scott Cotton wrote: > 1. "defer go"   extend defers to work on goroutine exit with > mechanism just  > like defer, but if we say "defer go f()" > instead of "defer f()" then we run on goroutine exit.  Very big gains > for  > scaling here IMHO. How is this differ

Re: [go-nuts] Go IO/SPI broken?

2017-10-16 Thread Dan Kortschak
Try using the periph.io libraries; golang.org/x/exp/io/spi is no longer maintained[1]. [1]https://github.com/golang/go/issues/22058#issuecomment-332390766 On Sun, 2017-10-15 at 21:01 -0700, Eugene Dzhurinsky wrote: > Hello!  > > I was trying to make the RF522 (RFID reader) to initialize properly

Re: [go-nuts] nil maps

2017-10-16 Thread Dan Kortschak
If you only need the map conditionally, you need to declare it and then conditionally make it. ``` var m map[string]int if needMap {     m = make(map[string]int) } ``` On Mon, 2017-10-16 at 21:52 -0700, Alex Dvoretskiy wrote: > Hello, Golang Nuts! > > I have an interesting question about maps. W

Re: [go-nuts] Re: awesome-go project on golang github organization

2017-10-24 Thread Dan Kortschak
I have similar sentiments. On Tue, 2017-10-24 at 09:19 -0700, prades.m...@gmail.com wrote: > I submitted several original projects i made to your list, they > passed all  > the tests, they sat in the pull-request list for 6 month then when > rejected  > for disingenuous or unspecified reasons.So I

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

2017-10-24 Thread Dan Kortschak
The spec does preclude that since there must be a `package main`. https://golang.org/ref/spec#Program_execution On Wed, 2017-10-25 at 05:02 +, Alex Buchanan wrote: > Interesting, thanks. Let me try to clarify my idea with some simple > code: > > // file lives at github.com/buchanae/foobar/fo

[go-nuts] append to a stem racy?

2017-11-05 Thread Dan Kortschak
Say I have a []T that I want to use as a common stem that has a tail appended onto it, used concurrently, for example: for i := 0; i < N; i++ { tail := makeTail(i) // Returns a []T. wg.Add(1) go func() { defer wg.Done() a := append(stem, tail

Re: [go-nuts] append to a stem racy?

2017-11-05 Thread Dan Kortschak
With high N, I have been able to confirm raciness. On Mon, 2017-11-06 at 11:13 +1030, Dan Kortschak wrote: > I have not been able to get the race detector to complain about this, > even if I make len << cap. -- You received this message because you are subscribed to the Google Gro

Re: [go-nuts] A way to detect closed channel

2017-11-06 Thread Dan Kortschak
No. The complete select+code blocks is not atomic, so the select may see that closedchan is not closed, execute the default case, but in the mean time closedchan has been closed by someone else. Bang! On Mon, 2017-11-06 at 16:59 -0800, Albert Tedja wrote: > Since closing an already closed channel

Re: [go-nuts] Re: A way to detect closed channel

2017-11-06 Thread Dan Kortschak
This is not a good idea (and is wrong since it does not check the ok value of the receive operation). As was pointed out previously, this is only true in the instant that the select is occurring. On Mon, 2017-11-06 at 18:39 -0800, sheepbao wrote: > func isClose() bool { >     select { >     case <

Re: [go-nuts] Simple exec.Command() program

2017-11-12 Thread Dan Kortschak
exec.Command does not invoke a shell, the `>' you use in bash is a shell function (https://www.gnu.org/software/bash/manual/bash.html#Redi rections). Note that the example for CombinedOutput invokes "sh" as the command with "-c", "ls... (https://golang.org/pkg/os/exec/#example_Cmd_ CombinedOutput).

Re: [go-nuts] Can someone explain this behavior with interfaces/points?

2017-11-14 Thread Dan Kortschak
This is explained in the FAQ: https://golang.org/doc/faq#nil_error On Tue, 2017-11-14 at 16:37 -0800, Travis Beauvais wrote: > https://play.golang.org/p/76gIgzXgcS > > Why is err not nil when a is? > > Our theory is that err is a pointer to a nil pointer so technically > not  > nil. We would hav

Re: [go-nuts] os.remove is slow

2017-12-04 Thread Dan Kortschak
Have you tried os.RemoveAll("/var/spool/directory")? https://golang.org/pkg/os/#RemoveAll If that's slow, file an issue. On Mon, 2017-12-04 at 09:41 -0800, gabejessfors...@gmail.com wrote: > What takes 18 seconds in a perl command: > perl -e 'for(<*>){((stat)[9]<(unlink))}' > > is taking almost

Re: [go-nuts] Re: Why is the cpu usage so high in a golang tcp server?

2017-12-19 Thread Dan Kortschak
bufio.NewReader On Mon, 2017-12-18 at 05:11 -0800, Tamás Gulácsi wrote: > > n, err := sock.Read(buf) > > > > > This will be slow: TCP is a streaming protocol, so this Read can read > any  > length between 0 (! yes !) and 1024 bytes. > Use buffering (bytes.NewReader) and some kind of messag

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] 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] 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-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] 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] 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] 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
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
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] 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] 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="" GO

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

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. https://play.golang.org/p/28y-zWhvoQ

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 &r2 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] 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. Variousl

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 f

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] 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). O

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 dissatisf

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

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 (mis)development

Re: [go-nuts] Recover considered harmful

2017-04-25 Thread Dan Kortschak
On Tue, 2017-04-25 at 03:06 +, Kevin Conway wrote: > The convention in the Go libraries is that even when a package uses > panic internally, its external API still presents explicit error > return values. reflect? All rules are wrong. -- You received this message because you are subscribed

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] Re: issues about struct align

2017-05-21 Thread Dan Kortschak
This smells like the XY problem. What are you actually trying to do and how have to tried to do it (actual code, not simplified analogues)? On Sun, 2017-05-21 at 23:05 -0700, xjdrew wrote: > How can i use this kind of Go in windows? my machine is 64bit also. > If I  > download the amd64 Go, the po

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

2017-05-29 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 run

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

2017-05-29 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

Re: [go-nuts] Go For Data analysts

2017-06-01 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 c

Re: [go-nuts] How can I read private field in go struct instance

2019-06-03 Thread Dan Kortschak
Sorry, missed the go- prefix in Dave's package. github.com/davecgh/go-spew On Tue, 2019-06-04 at 09:48 +0930, Dan Kortschak wrote: > There are packages already available for this. > > github.com/kortschak/utter (for Go syntax-like printing) > github.com/davecgh/spew (for le

Re: [go-nuts] How can I read private field in go struct instance

2019-06-03 Thread Dan Kortschak
There are packages already available for this. github.com/kortschak/utter (for Go syntax-like printing) github.com/davecgh/spew (for less Go syntax-like printing) On Mon, 2019-06-03 at 08:54 -0700, 杜沁园 wrote: > I recently write a program to recursively print all fields and value > in a  > struc

Re: [go-nuts] How can I read private field in go struct instance

2019-06-03 Thread Dan Kortschak
在 2019年6月4日星期二 UTC+8上午8:19:55,kortschak写道: > > > > > > Sorry, missed the go- prefix in Dave's package.  > > > > github.com/davecgh/go-spew  > > > > On Tue, 2019-06-04 at 09:48 +0930, Dan Kortschak wrote:  > > > > > > There are

[go-nuts] how to prevent go1.13 go directive being written in an go directive-free go.mod?

2019-06-10 Thread Dan Kortschak
The semantics of this line of go.mod is not described anywhere, but the tool chain blithely writes it to a go.mod file when there is no go directive present. Is there a way to mark the go.mod as go version-agnostic? -- You received this message because you are subscribed to the Google Groups "g

Re: [go-nuts] how to prevent go1.13 go directive being written in an go directive-free go.mod?

2019-06-10 Thread Dan Kortschak
x, but no other apparent value. [1]https://github.com/golang/go/issues/30791#issuecomment-472431458 On Mon, 2019-06-10 at 22:27 -0700, Ian Lance Taylor wrote: > On Mon, Jun 10, 2019 at 9:56 PM Dan Kortschak > wrote: > > > > > > The semantics of this line of go.mod is not d

Re: [go-nuts] how to prevent go1.13 go directive being written in an go directive-free go.mod?

2019-06-11 Thread Dan Kortschak
Thanks, Ian. Comments in-line. On Tue, 2019-06-11 at 06:42 -0700, Ian Lance Taylor wrote: > On Tue, Jun 11, 2019 at 6:40 AM Ian Lance Taylor > wrote: > > > > On Mon, Jun 10, 2019 at 10:51 PM Dan Kortschak > > wrote: > > > > > > The semantics of th

Re: [go-nuts] how to prevent go1.13 go directive being written in an go directive-free go.mod?

2019-06-11 Thread Dan Kortschak
(f2a4c13). Dan On Tue, 2019-06-11 at 17:35 -0700, Ian Lance Taylor wrote: > On Tue, Jun 11, 2019 at 4:53 PM Dan Kortschak > wrote: > > > > > > It would be very nice if the documentation and clarity of > > communication > > around this were improved. &g

Re: [go-nuts] how to prevent go1.13 go directive being written in an go directive-free go.mod?

2019-06-12 Thread Dan Kortschak
Thanks, Ian. I'll look later today. Dan On Wed, 2019-06-12 at 07:01 -0700, Ian Lance Taylor wrote: > On Tue, Jun 11, 2019 at 6:30 PM Dan Kortschak > wrote: > > > > Having that and exactly what it means in the go help modules output > > would probably be the bes

Re: [go-nuts] how to prevent go1.13 go directive being written in an go directive-free go.mod?

2019-06-12 Thread Dan Kortschak
For others, the cl is https://golang.org/cl/181840 (note the extra 0). On Wed, 2019-06-12 at 07:01 -0700, Ian Lance Taylor wrote: > On Tue, Jun 11, 2019 at 6:30 PM Dan Kortschak > wrote: > > > > Having that and exactly what it means in the go help modules output > > wo

Re: [go-nuts] how to prevent go1.13 go directive being written in an go directive-free go.mod?

2019-06-12 Thread Dan Kortschak
I feel your pain. For me it's at the other end of the keyboard. Dan On Wed, 2019-06-12 at 17:01 -0700, Ian Lance Taylor wrote: > On Wed, Jun 12, 2019 at 2:55 PM Dan Kortschak > wrote: > > > > For others, the cl is https://golang.org/cl/181840 (note the extra > &

Re: [go-nuts] Go Language Survey

2019-06-12 Thread Dan Kortschak
This is interesting. I have exactly the opposite situation; up-down is much easier than significant left-right because of faulty saccades. On Wed, 2019-06-12 at 11:41 -0700, Michael Jones wrote: > Bakul, more good arguments. I have another motivation in the "?" > world that > I've not argued becau

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

2019-06-29 Thread Dan Kortschak
That's not what Andrey wrote; he said if you want java error handling us java. No where in his post was any explicit value judgement on the approach. On Sat, 2019-06-29 at 15:41 -0500, Robert Engels wrote: > And Go has advantages over in many areas so stating “if you want > decent error handling u

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

2019-06-29 Thread Dan Kortschak
-06-29 at 18:27 -0500, Robert Engels wrote: > It was certainly implied given the context - Java’s superior error > handling will not make it to Go (for a variety of reasons), so if you > want it, use Java. > > Oh, and his reply pretty much backs my analysis :) > > > > On Ju

Re: [go-nuts] Counter-counter-counter proposals

2019-06-30 Thread Dan Kortschak
Thank you for sending that. That is a wonderful interview. On Sun, 2019-06-30 at 19:49 -0700, Michael Jones wrote: > With so many strongly worded emotional emails flying it might be > helpful to > remember that language design is about other people and other use > cases > than your own. The truly

Re: [go-nuts] Reflection: How to retrieve index of map

2019-07-01 Thread Dan Kortschak
You can use the Index method on reflect.Value if it is an integer- indexable type. https://play.golang.org/p/07YXRPBMqo6 On Mon, 2019-07-01 at 12:45 -0700, Mark Bauermeister wrote: > I have the following code, where the TokenMap struct is actually part > of another package. > idMap is not export

Re: [go-nuts] Re: ioutil.ReadDir sort order

2019-07-06 Thread Dan Kortschak
It's sorted lexically by the unicode code points. Why would str1 come after str2? '1' < '9'. On Fri, 2019-07-05 at 21:23 -0700, shubham.pendharkar via golang-nuts wrote: > It sorts by name, but there is a big problem with golang string > comparison. > If you consider these two strings: > str1 : "h

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

2019-07-09 Thread Dan Kortschak
This is not necessarily true. A single call may return a variety of errors. Otherwise a simple (ok bool) would be enough. On Tue, 2019-07-09 at 15:49 +0200, Nicolas Grilly wrote: > On Tue, Jul 9, 2019 at 3:36 PM Wojciech S. Czarnecki > > wrote: > > > Because given piece of contemporary productio

Re: [go-nuts] Include tests in binary and run them

2019-07-09 Thread Dan Kortschak
You can ask go test to leave the test executable for you to use later. This is done with the -c flag. It will leave a -test binary that takes all the flags that go test takes. This is at least similar to what you are asking for. On Tue, 2019-07-09 at 18:35 -0700, farid.m.zaka...@gmail.com wrote: >

Re: [go-nuts] Go NaCl and C NaCl/libsodium

2019-07-12 Thread Dan Kortschak
Different type of salt here. This is Networking and Cryptography library, not Native Client. On Fri, 2019-07-12 at 21:33 -0700, Ian Lance Taylor wrote: > On Fri, Jul 12, 2019 at 9:28 PM mike wrote: > > > > Does anyone have any sample code which shows interoperability > > between Go's golang.org/

Re: [go-nuts] About the Google logo on the new Go website

2019-07-15 Thread Dan Kortschak
Fair or not, it's pretty tone deaf. In conjunction with other unilateral decisions that get made, it leads to a sour taste. On Mon, 2019-07-15 at 18:54 +0200, Wojciech S. Czarnecki wrote: > On Mon, 15 Jul 2019 17:39:47 +0200 > Michal Strba wrote: > > > The issue was promptly closed and locked by

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

2019-07-15 Thread Dan Kortschak
This is what the go version directive in go.mod is for. On Mon, 2019-07-15 at 20:05 -0700, Andrey Tcherepanov wrote: > Or... adding "require" to package statement to indicate Go 2 is the > language for this file > > package main requires "go2" -- You received this message because you are subsc

Re: [go-nuts] About the Google logo on the new Go website

2019-07-16 Thread Dan Kortschak
The headline of the group is "Welcome to golang-nuts, a general discussion list for the Go Programming Language." I'd say this is that, a discussion related to the Go Programming Language. On Tue, 2019-07-16 at 11:33 +0200, Wojciech S. Czarnecki wrote: > On Mon, 15 Jul 2019 17:05:40 + > "Sam

Re: [go-nuts] Re: Go for Data Science

2019-07-16 Thread Dan Kortschak
We'd (gonum-dev) likely advise not to use julia for reasons that I won't go into here. However, I can suggest that the OP checks out the data-science channel on https://gophers.slack.com/ Also note that gorgonia does data-flow graph compilation described Jesper, and there are REPLs that are avail

Re: [go-nuts] Re: Go for Data Science

2019-07-16 Thread Dan Kortschak
There is a project that is intended to implement pandas-like data manip: https://github.com/ptiger10/pd On Tue, 2019-07-16 at 16:06 -0700, Leo R wrote: > Regarding REPL in Go, it is complicated. Currently, lgo seems to be > broken > as of go-1.12 (and go-1.13), see README.md in their repo > htt

Re: [go-nuts] Re: About the Google logo on the new Go website

2019-07-16 Thread Dan Kortschak
The ™ thing is likely defensive, to avoid this kind of problem https://www.informationweek.com/google-go-name-brings-accusations-of-evil/d/d-id/1084786 Here is the USPTO record: http://tmsearch.uspto.gov/bin/showfield?f=doc&state=4805:l86u0m.6.2 On Wed, 2019-07-17 at 01:13 +0300, Space A. wrote

Re: [go-nuts] Panic not recovered inside my panic recover function

2019-07-17 Thread Dan Kortschak
The defer is not being run directly as a result of the panic. >From the spec: > The recover function allows a program to manage behavior of a > panicking goroutine. Suppose a function G defers a function D that > calls recover and a panic occurs in a function on the same goroutine > in which G is

Re: [go-nuts] Panic not recovered inside my panic recover function

2019-07-17 Thread Dan Kortschak
You could try it this way if you really need a separate function. https://play.golang.org/p/V-ysjWbZ2X5 On Thu, 2019-07-18 at 12:51 +0800, ZP L wrote: > Sorry for the bad formatting. > > > recover must be called directly by a deferred function > > func logPanic() { > defer func() { > if

Re: [go-nuts] time.Format vs. fmt.Sprintf

2019-07-23 Thread Dan Kortschak
2019-07-23 at 18:45 -0500, Robert Engels wrote: > Funny. Did you remember it or just pay close attention to these > things? > > > On Jul 23, 2019, at 6:38 PM, Dan Kortschak > > wrote: > > > > This thread is 7 years old. > > > > > On Tue, 2019-0

Re: [go-nuts] time.Format vs. fmt.Sprintf

2019-07-24 Thread Dan Kortschak
> > On Jul 23, 2019, at 9:38 PM, Dan Kortschak > > wrote: > > > > I couldn't find the thread in my go-nuts box, so I looked for it on > > google groups. > > > > Chris, it may be relevant, but the thread is stale and so the > > conversation is

Re: [go-nuts] SIGSEGV in io.copyBuffer

2019-07-30 Thread Dan Kortschak
This looks like a QEMU thing more than a Go thing. On Tue, 2019-07-30 at 02:15 -0700, antony.rhen...@gmail.com wrote: > Seeing segfault during go get -v URL > > > > $ go version > go version go1.11.5 linux/arm > > > > $ go env > GOARCH="arm" > GOBIN="" > GOCACHE="/var/arheneus/.cache/go-buil

Re: [go-nuts] Re: SIGSEGV in io.copyBuffer

2019-07-30 Thread Dan Kortschak
Do you have any reason to believe that it's not QEMU (have you done this on real hardware)? It has past form for this kind of problem. I have just tried to replicate this on a pi and both 1.11.5 and 1.11.9 complete successfully. BTW 1.11 is not the the current release and for 1.11, the most recen

Re: [go-nuts] Parsing go.mod

2019-09-02 Thread Dan Kortschak
Not really exposed, but there is code you could copy. https://golang.org/pkg/cmd/go/internal/modfile/#Parse On Mon, 2019-09-02 at 22:44 -0700, James Pettyjohn wrote: > Hi, > > This might be a bad idea but I'm trying to parse the go.mod file for > data > as part of my build process - if at all p

Re: [go-nuts] Re: v1.13: Altered go.mod file in project after updating vim-go binaries

2019-09-05 Thread Dan Kortschak
I also. We have to add additional mess to our build scripts when we get testing dependencies that are not part of our distribution to avoid contaminating the go.{mod,sum} in the repo root. This has repeatedly been a source of irritation and frustration. Dan On Thu, 2019-09-05 at 11:36 -0700, Mi

Re: [go-nuts] Clarification on unsafe conversion between string <-> []byte

2019-09-20 Thread Dan Kortschak
func bytesToString(b []byte) string { return *(*string)(unsafe.Pointer(&b)) } https://play.golang.org/p/azJPbl946zj On Fri, 2019-09-20 at 13:30 -0700, Francis wrote: > Thanks Ian, that's a very interesting solution. > > Is there a solution for going in the other direction? Although I > e

Re: [go-nuts] Clarification on unsafe conversion between string <-> []byte

2019-09-23 Thread Dan Kortschak
Any particular reason for that? Neither is safer than the other and it's not clear to me that you can actually achieve the goal of having a compile-time check for the correctness of this type of conversion. On Mon, 2019-09-23 at 02:36 -0700, fran...@adeven.com wrote: > But this relies on a string'

[go-nuts] package_test can't find local package

2019-09-23 Thread Dan Kortschak
I'm putting together a tiny package at the moment that has not yet been push to a git remote. When I try to run tests I get the following failure: $ GOPROXY=off go test # yaegiconf package yaegiconf_test imports github.com/kortschak/yaegiconf: cannot find module providing package github.co

Re: [go-nuts] package_test can't find local package

2019-09-23 Thread Dan Kortschak
Resolved. Module name must be fully qualified. On Tue, 2019-09-24 at 11:19 +0930, Dan Kortschak wrote: > I'm putting together a tiny package at the moment that has not yet > been > push to a git remote. When I try to run tests I get the following > failure: > >

[go-nuts] using Go as a configuration file format

2019-09-23 Thread Dan Kortschak
Have you ever considered using Go as the configuration format for your project? Have you wondered whether you need a Turing complete configuration language? Of course not; here it is: https://github.com/kortschak/yaegiconf Appalled? OK. -- You received this message because you are subscribed to

Re: [go-nuts] nil map assignment panics. can we do better?

2019-09-24 Thread Dan Kortschak
You can write that. func insert(m map[K]V, k K, v V) map[K]V { if m == nil { return map[K]V{k: v} } m[k] = v return m } On Tue, 2019-09-24 at 13:10 -0700, Marcin Romaszewicz wrote: > Could we have an operation like append() for slices? > > How abou

[go-nuts] missing $GOPATH

2019-09-26 Thread Dan Kortschak
I am looking at some changes we have made to make code generation independent of GOPATH since from the SettingGOPATH page of the wiki says "If no GOPATH is set, it is assumed to be $HOME/go on Unix systems and %USERPROFILE%\go on Windows." However, when I run `go env` I see `missing $GOPATH` in re

Re: [go-nuts] missing $GOPATH

2019-09-26 Thread Dan Kortschak
Yes, that explains it. Perhaps the error could be more informative. On Thu, 2019-09-26 at 20:19 -0700, Ian Lance Taylor wrote: > On Thu, Sep 26, 2019 at 7:36 PM Dan Kortschak > wrote: > > > > I am looking at some changes we have made to make code generation > > independ

Re: [go-nuts] missing $GOPATH

2019-09-26 Thread Dan Kortschak
[1]https://go-review.googlesource.com/c/go/+/33105/ [2]https://go-review.googlesource.com/c/go/+/118095/ On Fri, 2019-09-27 at 12:51 +0930, Dan Kortschak wrote: > Yes, that explains it. Perhaps the error could be more informative. > > On Thu, 2019-09-26 at 20:19 -0700, Ian Lance Taylor wrote:

Re: [go-nuts] missing $GOPATH

2019-09-30 Thread Dan Kortschak
Filed https://golang.org/issue/34628 On Fri, 2019-09-27 at 15:19 +0930, Dan Kortschak wrote: > Looking into it it appears that there's active work in > go/build.defaultGOPATH that makes returning an informative error > message impossible. > > This made sense when it was d

[go-nuts] geocrypt package

2019-10-11 Thread Dan Kortschak
Over 10 years ago Gustavo Niemeyer invented the geohash geographic hashing system https://en.wikipedia.org/wiki/Geohash for clearly and concisely representing geographic locations at arbitrary precision. Now, here is geocrypt, a package that returns or checks a cryptographic hash of a geolocation.

<    1   2   3   4   5   6   7   >