Re: [go-nuts] The strange behavior of defer

2019-05-20 Thread Dan Kortschak
The parameter to fmt.Println is evaluated at the time of the defer statement's execution. You should do something like this instead func main() { start := time.Now() defer func() { fmt.Println(time.Since(start)) }() time.Sleep(10) fmt.Println("Hello,

Re: [go-nuts] How to detect source of a dependency in go.mod

2019-05-08 Thread Dan Kortschak
Try github.com/sirupsen/logrus@v1.4.1 At some point the capitalisation was changed. On Tue, 2019-05-07 at 19:16 -0700, tamal wrote: > I am trying to convert https://github.com/appscode/voyager from glide > to go  > mod. > > I am getting an error like below: > ``` > go:

Re: [go-nuts] multiple array declaration.. Is there a easier way ?

2019-05-01 Thread Dan Kortschak
var T0, T1, T2, T3, T5 [256]uint32 https://play.golang.org/p/6Cm4p_NyD8m On Wed, 2019-05-01 at 18:40 -0700, lgod...@gmail.com wrote: > The following statement seems very awkward, is there a cleaner way to > write  > it ? > > var T0= [256]uint32;  var T1= [256]uint32; var T2= [256]uint32; var >

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 :

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

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

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

2019-06-29 Thread Dan Kortschak
-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 Jun 29, 2019, at

Re: [go-nuts] why does reading a file on windows add CRLF to unix line endings... sometimes?

2019-04-22 Thread Dan Kortschak
Solved. This is Travis being "helpful" and setting core.autocrlf=true in git config. https://travis-ci.community/t/files-in-checkout-have-eol-changed-from-l f-to-crlf/349/4 On Tue, 2019-04-23 at 07:50 +0930, Dan Kortschak wrote: > I have a test that is failing on travis on a wind

[go-nuts] why does reading a file on windows add CRLF to unix line endings... sometimes?

2019-04-22 Thread Dan Kortschak
I have a test that is failing on travis on a windows build due to the presence of CRLF in the bytes returned by ioutil.ReadFile. The file itself uses unix line endings, so the CR is inserted by something somewhere along the line. However, this is not always the case. On AppVeyor, I do not see

Re: [go-nuts] Go+ replacement

2019-04-21 Thread Dan Kortschak
This is unfortunate. It was less like that in the past. On Sun, 2019-04-21 at 18:02 -0700, icod.d...@gmail.com wrote: > Nuts is more of a "help I have a problem" thing. -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this

Re: [go-nuts] Re: Go if else syntax .. suggested replacement

2019-04-24 Thread Dan Kortschak
How would you preclude it? On Wed, 2019-04-24 at 16:28 -0700, lgod...@gmail.com wrote: > I am NOT in favor of allowing nested ternary operations -- 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] Re: Go if else syntax .. suggested replacement

2019-04-24 Thread Dan Kortschak
de block for test=true > case false: >   //..code block for test=false > } > > On Wed, Apr 24, 2019 at 4:42 PM Dan Kortschak > wrote: > > > > > How would you preclude it? > > > > On Wed, 2019-04-24 at 16:28 -0700, lgod...@gmail.com wrote: > > &

Re: [go-nuts] Go if else syntax .. suggested replacement

2019-04-25 Thread Dan Kortschak
The difference is that the ternary operator is an expression and the if...else is a statement. If you're only suggesting a syntax change, then the difference becomes one of readability. I'll ask again, how would you preclude nesting without making the language more complex? On Thu, 2019-04-25 at

Re: [go-nuts] Go if else syntax .. suggested replacement

2019-04-25 Thread Dan Kortschak
Please understand that my use of ?: in the proposed grammar is irrelevant. Using the syntax proposed here leads to the same problem. You have self contradictory claims below: 1. the change is only a swapping of 'if' => '?' and 'else' => ':' with no semantic change: "My proposal  

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

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=4805:l86u0m.6.2 On Wed, 2019-07-17 at 01:13 +0300, Space A. wrote: >

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 >

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

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

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

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,

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

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

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

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
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-07-23 at 12

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

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

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 unlik

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

2019-09-21 Thread Dan Kortschak
func bytesToString(b []byte) string { return *(*string)(unsafe.Pointer()) } 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 >

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 done i

[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: [go-nuts] missing $GOPATH

2019-09-26 Thread Dan Kortschak
-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: > > On Th

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

[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

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: > > $ G

[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

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

Re: [go-nuts] go.dev is live!

2019-11-13 Thread Dan Kortschak
Also, the license feedback link at https://pkg.go.dev/license-policy fails to work on Firefox. On Thu, 2019-11-14 at 15:24 +1030, Dan Kortschak wrote: > Hi, > > It looks like license detection needs work. > > See https://pkg.go.dev/gonum.org/v1/gonum?tab=overview and note it

[go-nuts] Re: [golang-dev] go.dev is live!

2019-11-13 Thread Dan Kortschak
Hi, It looks like license detection needs work. See https://pkg.go.dev/gonum.org/v1/gonum?tab=overview and note it has a BSD 3 clause, as shown by GitHub's assessment (just above the "Clone or download" button) at https://github.com/gonum/gonum and the LICENSE file that it links to. Dan On

[go-nuts] no returned name or package path from reflect.Type?

2019-11-22 Thread Dan Kortschak
Are reflect.Type.PkgPath/Name supposed to return strings for defined types? There's nothing in the documentation that says they don't. But https://play.golang.org/p/8Jede-mimtA and https://play.golang.org/p/LT5m6yz0P5Y don't show any output where I would expect them to. Dan -- You received

Re: [go-nuts] no returned name or package path from reflect.Type?

2019-11-22 Thread Dan Kortschak
Thanks. That continues to trip me up. On Fri, 2019-11-22 at 17:01 -0800, Ian Lance Taylor wrote: > On Fri, Nov 22, 2019 at 1:06 PM Dan Kortschak > wrote: > > > > Are reflect.Type.PkgPath/Name supposed to return strings for > > defined > > types? There's nothing

Re: [go-nuts] no returned name or package path from reflect.Type?

2019-11-22 Thread Dan Kortschak
Solved. Because they are not named types (being the pointer to the type). On Sat, 2019-11-23 at 07:36 +1030, Dan Kortschak wrote: > Are reflect.Type.PkgPath/Name supposed to return strings for defined > types? There's nothing in the documentation that says they don't. > &g

Re: [go-nuts] Is anyone aware of a blocking ring buffer implementation?

2019-11-21 Thread Dan Kortschak
There is this: https://godoc.org/bitbucket.org/ausocean/utils/ring It has been used in production fairly extensively. On Thu, 2019-11-21 at 19:47 -0800, Marcin Romaszewicz wrote: > Hi All, > > Before I reinvent the wheel, and because this wheel is particularly > tricky > to get right, I was

Re: [go-nuts] querying whether the go command would run in module mode

2019-12-09 Thread Dan Kortschak
> On Mon, 9 Dec 2019, 00:25 Dan Kortschak, wrote: > > > Is there a way to query whether an invocation of the go command > > would > > be running in module mode? > > > > thanks > > Dan > > > > -- > > You received this message bec

Re: [go-nuts] querying whether the go command would run in module mode

2019-12-09 Thread Dan Kortschak
Thanks. Yes, I always have GO111MODULE=on, hence the difference. On Mon, 2019-12-09 at 10:04 +, Paul Jolly wrote: > > When you're not in a module it returns /dev/null on linux. I don't > > suppose this is platform independent? > > I have to say what you saw surprised me until Daniel Martí

[go-nuts] querying whether the go command would run in module mode

2019-12-08 Thread Dan Kortschak
Is there a way to query whether an invocation of the go command would be running in module mode? thanks Dan -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receiving emails from it, send an email to

Re: [go-nuts] cgo & long jump

2019-12-09 Thread Dan Kortschak
This breaks my already fairly tenuous grasp of the progression of time; what do you mean by since "since then" when that event is a personal that is in the past (do you mean between going to sleep in the future and waking up in the past). Time [travel] is hard. On Mon, 2019-12-09 at 11:24 -0800,

Re: [go-nuts] Re: help with reflect

2019-12-09 Thread Dan Kortschak
On Mon, 2019-12-09 at 14:57 +0300, Vasiliy Tolstov wrote: > Nevermind. I found the error https://paulcunningham.me/nevermind-found-answer/ -- 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] types lookup for error interface type

2019-12-14 Thread Dan Kortschak
In the go/types package there is an easy way to obtain a types.Type for basic builtin types. This doesn't exist for the error type. Is there an easier way to get a types.Type representing error than by using NewInterfaceType, NewFunc and NewSignature functions (I am assuming that the nil

Re: [go-nuts] types lookup for error interface type

2019-12-14 Thread Dan Kortschak
complicated, so I'm wondering if there is an easier way. On Sat, 2019-12-14 at 19:37 +1030, Dan Kortschak wrote: > In the go/types package there is an easy way to obtain a types.Type > for > basic builtin types. This doesn't exist for the error type. > > Is there an easier way to g

Re: [go-nuts] types lookup for error interface type

2019-12-14 Thread Dan Kortschak
I think you are right. Thanks. On Sat, 2019-12-14 at 19:20 +, Paul Jolly wrote: > > This seem massively over complicated, so I'm wondering if there is > > an > > easier way. > > I think you're after types.Universe.Lookup("error")? > > > Paul > -- You received this message because you

[go-nuts] cgo wrapper function not working in buildmode=c-shared with exported function

2019-12-05 Thread Dan Kortschak
I am trying to write a shared module that will be called from C, but I have run into a problem in using the work-around in https://github.com/golang/go/wiki/cgo#the-basics for calling variadic C functions. The case that I have is more complex, but altering the example at the wiki demonstrates

Re: [go-nuts] cgo wrapper function not working in buildmode=c-shared with exported function

2019-12-05 Thread Dan Kortschak
) > C.myprint(cs) > C.free(unsafe.Pointer(cs)) > } > > func main() { > Example() > } > $ cat cfunc.go > package main > > /* > #include > #include > > void myprint(char* s) { > printf("%s\n", s); > } > */ > import

Re: [go-nuts] cgo wrapper function not working in buildmode=c-shared with exported function

2019-12-05 Thread Dan Kortschak
s, it must not contain > any definitions, only declarations. If a file contains both > definitions and declarations, then the two output files will produce > duplicate symbols and the linker will fail. To avoid this, > definitions > must be placed in preambles in other file

[go-nuts] getting a function docs when you have a *packages.Package

2019-12-06 Thread Dan Kortschak
I want to be able to extract function documentation in addition to a variety of other information. I have a *packages.Package from packages.Load. Is there an easy way to get the function documentation from this. At the moment I am obtaining a *doc.Package using the following code, but it seems

Re: [go-nuts] Re: getting a function docs when you have a *packages.Package

2019-12-07 Thread Dan Kortschak
I completely missed the .Doc field in the ast.FuncDecl type. That's perfect. Thanks. On Sat, 2019-12-07 at 03:47 -0800, Charith Ellawala wrote: > I am searching for a good way of doing this myself. An approach that > seems > to work reasonably well is to just iterate through the AST files and >

Re: [go-nuts] Re: Slices, backing array, goroutines, perhaps Considerations for Go2

2019-10-27 Thread Dan Kortschak
This is not necessarily due to races. You can have this exact situation occurring in single threaded code. I don't think any mention of race issues was made here. On Sun, 2019-10-27 at 08:53 +, roger peppe wrote: > On Sun, 27 Oct 2019, 00:04 Gert, wrote: > > > I believe it's going to be to

Re: [go-nuts] Re: Slices, backing array, goroutines, perhaps Considerations for Go2

2019-10-28 Thread Dan Kortschak
You are absolutely right. Apologies. On Mon, 2019-10-28 at 08:43 +, roger peppe wrote: > On Sun, 27 Oct 2019, 21:31 Dan Kortschak, wrote: > > > This is not necessarily due to races. You can have this exact > > situation > > occurring in single threaded code. I

[go-nuts] specifying module dependency versions with the present playground

2019-10-29 Thread Dan Kortschak
I am wanting to demonstrate some difference in behaviours with different versions of a dependency using the present playground. However, the go.mod file in the directory holding the code is ignored. Running the commands that golang.org/x/tools/playground (the backend I'm using) respects the go.mod

Re: [go-nuts] Where is the middle of Brazil?

2019-12-01 Thread Dan Kortschak
This looks like a job for geocrypt :) https://godoc.org/github.com/kortschak/geocrypt On Sun, 2019-12-01 at 06:37 -0300, JuciÊ Andrade wrote: > Andrew, the solution doesn't involve cracking the digest at all. As I > said above, maybe I should have been clearer in my question. That > digest is

Re: [go-nuts] Разбить массив чисел на два массива

2019-12-01 Thread Dan Kortschak
What do you mean by i+k >= cap(a)? k+(any non-negative number) may not be greater than cap(a). The key to safely appending when you are unsure of the backing array's state is to append to the slice length and capped to the same size. On Sun, 2019-12-01 at 14:55 -0800, Bakul Shah wrote: >

Re: [go-nuts] using or extending or forking+renaming github.com/google/licensecheck to provide similar functionality

2019-11-14 Thread Dan Kortschak
The licensecheck.Match type holds the start and end offsets in the file. Can't you use that to extract the license portion and either check it's length against the length of the license or repeat the Check with only that portion of the file? On Thu, 2019-11-14 at 10:24 +0100, fge...@gmail.com

Re: [go-nuts] Re: [golang-dev] go.dev is live!

2019-11-14 Thread Dan Kortschak
original sources have their licenses represented as well. On Thu, 2019-11-14 at 10:56 +0100, Jan Mercl wrote: > On Thu, Nov 14, 2019 at 5:55 AM Dan Kortschak > wrote: > > > It looks like license detection needs work. > > > > See https://pkg.go.dev/gonum.org/v1/gonum?tab=o

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

[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

[go-nuts] arm64 builder on raspberry pi 3B/3B+

2020-02-11 Thread Dan Kortschak
I have been wanting an arm64 builder to do local testing for Gonum recently. Unfortunately, though RPi 3 and 4 have 64 bit cores, Raspbian is 32 bit, so they don't satisfy. However, I found this article[1] which goes through installing a UEFI bootloader and vanilla Debian Buster install on

Re: [go-nuts] Re: arm64 builder on raspberry pi 3B/3B+

2020-02-12 Thread Dan Kortschak
The builder is for running tests on GOARCH=arm64. I have previously run tests using qemu-arm, but this is currently broken (and is slow even when not broken). On Wed, 2020-02-12 at 00:15 -0800, Brian Candler wrote: > Interesting to know. > > When you say "an arm64 builder", I presume you already

Re: [go-nuts] Language proposal: labelled "with" statements to help make test code easier to write

2020-02-29 Thread Dan Kortschak
Why can't you spell "with" as "func"? On Sat, 2020-02-29 at 06:16 -0800, Warren Stephens wrote: > I often write a function or module to handle some process that takes > 3 or 4 steps to complete. > > After I am happy with the code I then proceed to write tests for the > code, > but find that I

Re: [go-nuts] Language proposal: labelled "with" statements to help make test code easier to write

2020-03-03 Thread Dan Kortschak
The answer to that question is entirely dependent on context, which is stripped by using anonymous labels as you have. For linear things, the second one is clearer, for hierarchical things the first is. It is entirely possible to test each piece of an hierarchical structure; this is the basis for

Re: [go-nuts] Significance of Mon Jan 2 15:04:05 -0700 MST 2006?

2020-02-28 Thread Dan Kortschak
Rob explained this in a thread a fair while back. > The choice was made by the output of the date command on my Unix > machine. I should have realized the format varies with locale. Mea > culpa. But I can still claim it's easy to remember and well > documented.

Re: [go-nuts] Re: Language proposal: labelled "with" statements to help make test code easier to write

2020-03-05 Thread Dan Kortschak
I'm really struggling to understand the benefit that you say you'll get. The linear form that the with: label gives you is really just what we already use with a different accent. The cost of testing or not is not substantially different, but the cost of allowing long linear functions, needing

Re: [go-nuts] Re: Language proposal: labelled "with" statements to help make test code easier to write

2020-03-06 Thread Dan Kortschak
I wrote cybernetic systems for laboratories with LabView a few decades ago. Nothing is worth keeping from that system. On Fri, 2020-03-06 at 00:59 -0800, Warren Stephens wrote: > How many good tools exist now that will turn linear code into a nice > looking readable flow chart? Few? None really?

Re: [go-nuts] Re: Why isn't there strings.reverse("str") function?

2020-02-27 Thread Dan Kortschak
Why? There's a single correctly sized allocation made up front and then a linear time walk along the encoded runes with truncation after each rune. On Thu, 2020-02-27 at 13:05 -0800, Amnon Baron Cohen wrote: > O(n^2) > > On Thursday, 27 February 2020 18:53:01 UTC, rog wrote: > > If you really

Re: [go-nuts] [Proposal] Change how gofmt formats struct fields

2020-01-29 Thread Dan Kortschak
I suspect Manlio was referring to something like this http://nickgravgaard.com/elastic-tabstops/. Dan On Thu, 2020-01-30 at 01:10 +0100, Wojciech S. Czarnecki wrote: > Dnia 2020-01-29, o godz. 09:56:35 > Manlio Perillo napisał(a): > > > What I propose is to use a tab between the field name

Re: [go-nuts] exec.Command() always returns error status of 1 when it was executed successfully

2020-02-17 Thread Dan Kortschak
What do you see when you bash -c "lspci | grep -i vga | grep -i nvidia" echo $? If you have no nvidia line or no vga line in lspci, this will output 1. On Mon, 2020-02-17 at 14:41 -0800, Dean Schulze wrote: > This command always sets the err to "exit status 1" even though it > executes

Re: [go-nuts] Directly assign map[string]int to map[string]interface{}?

2020-02-23 Thread Dan Kortschak
Have a read of https://research.swtch.com/interfaces. There you'll see that the memory layout of int and interface{} are not the same. This means you can't just treat one as the other, which essentially is what you are asking for. On Sun, 2020-02-23 at 01:12 -0800, Glen Huang wrote: > Hi, > > I

Re: [go-nuts] Re: Directly assign map[string]int to map[string]interface{}?

2020-02-23 Thread Dan Kortschak
Go is a statically typed language, but the time you get into the case, you must know the concrete type of the v. You allows it to be either map[string]interface{} or map[string]int, this is not a single known type, so the original input type (interface{}) is used. On Sun, 2020-02-23 at 01:24

Re: [go-nuts] Language spec question: why is k, v := k, v allowed in a for loop with range?

2020-01-12 Thread Dan Kortschak
The gopher operator is allowed to be used because the body of the for loop is a new scope. In the second example, the a, b := b, a is not in a new scope. On Sun, 2020-01-12 at 09:09 +0100, Silvan Jegen wrote: > Hi fellow gophers > > The following code compiles > > > package main > > import (

Re: [go-nuts] Language spec question: why is k, v := k, v allowed in a for loop with range?

2020-01-12 Thread Dan Kortschak
On Sun, 2020-01-12 at 10:10 +0100, Silvan Jegen wrote: > So the declaration of the variables in the for loop itself is in > outer scope compared to the body of the for loop? Yes. > In that case, redeclaring them in the inner scope (== the loop body) > would not be allowed either, no? What? The

[go-nuts] float behaviour on arm64 v amd64

2020-01-12 Thread Dan Kortschak
I am going through failures that I see in Gonum tests when we build on arm64 (Travis now provide this). In many cases there are slight differences that I'm OK with adding a tolerance to accept, but in one case (stat.ROC[0][1]) I see an error that can be completely avoided by changing the

Re: [go-nuts] Golang on ARMv5

2020-01-12 Thread Dan Kortschak
Yes, I use Go on ARMv5. AFAIK it still works. On Sun, 2020-01-12 at 12:51 -0800, Ian Lance Taylor wrote: > On Sun, Jan 12, 2020 at 10:17 AM wrote: > > > > Does anyone know where I can find a list of Go versions that > > includes the architectures supported and minimum kernel version > >

[go-nuts] Quantum mechanics mindshare is low & ~flat, per Google Trends

2020-01-15 Thread Dan Kortschak
Google Trends graph showing past 5y of Mechanic, Quantum mechanics https://trends.google.com/trends/explore?date=today%205-y=%2Fm%2F03f_s3,%2Fm%2F069dx -- 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] Sending Json Data with different types

2020-01-18 Thread Dan Kortschak
Try something like this: https://play.golang.org/p/hcI8eMo08Wx Your array type needs to be an interface type to allow the different value types. On Sat, 2020-01-18 at 12:30 -0800, ramkill...@hotmail.com wrote: > I have a server that requires data to be sent back that looks like > this > >

Re: [go-nuts] Re: float behaviour on arm64 v amd64

2020-01-13 Thread Dan Kortschak
Thanks for linking this here. One thing that I did not follow up at the issue; why do we see the FMA being applied when the value is a slice element, but not when it's a single float64 value? Second query, are there plans for adding FMA support to amd64 akin to how it is on arm64? Dan On Mon,

Re: [go-nuts] Re: float behaviour on arm64 v amd64

2020-01-13 Thread Dan Kortschak
dall wrote: > On Mon, Jan 13, 2020 at 5:45 PM Dan Kortschak > wrote: > > > Thanks for linking this here. > > > > One thing that I did not follow up at the issue; why do we see the > > FMA > > being applied when the value is a slice element, but not when it's > &

Re: [go-nuts] Testing Changes to a Forked Module Dependency (go.mod problems)

2020-01-01 Thread Dan Kortschak
Though also see https://github.com/golang/go/issues/26640 On Wed, 2020-01-01 at 23:24 -0700, burak serdar wrote: > On Wed, Jan 1, 2020 at 10:25 PM wrote: > > > > I've been working on something that uses a package that I have > > imported. > > > > During the development I wanted to improvement

[go-nuts] find module of dependent package

2019-12-23 Thread Dan Kortschak
Say I have a package path, "host.org/user/depmodule/pkgdep", which is the path to a dependency of "host.org/user/repomain/pkgmain". The go.mod file in host.org/user/repomain will have a line "host.org/user/depmodule" in the require block. If I want to programmatically find what the module path is

Re: [go-nuts] find module of dependent package

2019-12-23 Thread Dan Kortschak
Solved thanks to Daniel Martí; use `go list -json` and grab the Module struct out of that. On Tue, 2019-12-24 at 09:50 +1030, Dan Kortschak wrote: > Say I have a package path, "host.org/user/depmodule/pkgdep", which is > the path to a dependency of "host.org/user/repomain/p

Re: [go-nuts] Panicking in public API ?

2020-01-06 Thread Dan Kortschak
Speaking as someone who is probably to blame for a significant proliferation of public facing panics, that example is probably not a good place for it. There are uses in the standard library of public facing panics, but they generally fall into the categories of simulating the type system (in

Re: [go-nuts] MarshalJSON() output encrypted json

2019-12-27 Thread Dan Kortschak
MarshalText? On Fri, 2019-12-27 at 09:51 +0100, Gert Cuykens wrote: > Thanks, Which should I use instead then? The reason I use it is so I > can easily switch between regular json payloads for debugging and > encrypted/signed urlencode payloads > > On Fri, Dec 27, 2019 at 9:39 AM Axel Wagner >

Re: [go-nuts] MarshalJSON() output encrypted json

2019-12-27 Thread Dan Kortschak
ecause I have to > change > every json.Marshal and json.Umarshal > > On Fri, Dec 27, 2019 at 10:21 AM Dan Kortschak > wrote: > > > > MarshalText? > > > > On Fri, 2019-12-27 at 09:51 +0100, Gert Cuykens wrote: > > > Thanks, Which should I use ins

Re: [go-nuts] go test -race hanging with Go1.14, only with -a flag

2020-03-10 Thread Dan Kortschak
On Wed, 2020-03-11 at 05:25 +, Dan Kortschak wrote: > On Tue, 2020-03-10 at 22:07 -0700, Ian Lance Taylor wrote: > > On Tue, Mar 10, 2020 at 3:25 AM Dan Kortschak > > wrote: > > > > > > I have a package that is dependent on bazil.org/fuse for testing &

Re: [go-nuts] go test -race hanging with Go1.14, only with -a flag

2020-03-10 Thread Dan Kortschak
On Tue, 2020-03-10 at 22:07 -0700, Ian Lance Taylor wrote: > On Tue, Mar 10, 2020 at 3:25 AM Dan Kortschak > wrote: > > > > I have a package that is dependent on bazil.org/fuse for testing > > via a > > sysfs simulation package github.com/ev3go/sisyphus. &

Re: [go-nuts] An important proposal will fail without your support

2020-03-11 Thread Dan Kortschak
Ah, OK. On Wed, 2020-03-11 at 01:58 -0700, miha.vrhov...@gmail.com wrote: > https://github.com/golang/text/pull/9 > > And I cannot find the issue, but there are a few with extract command > not working and crashing. > > On Wednesday, March 11, 2020 at 9:40:36 AM UTC+1, kortschak wrote: > > Why

Re: [go-nuts] An important proposal will fail without your support

2020-03-11 Thread Dan Kortschak
Why do you say that? ~/src/golang.org/x/text/message [master*]$ go env GO111MODULE on ~/src/golang.org/x/text/message [master*]$ go version go version go1.14 linux/amd64 ~/src/golang.org/x/text/message [master*]$ go test PASS ok golang.org/x/text/message 0.024s On Wed, 2020-03-11 at

[go-nuts] go test -race hanging with Go1.14, only with -a flag

2020-03-10 Thread Dan Kortschak
I have a package that is dependent on bazil.org/fuse for testing via a sysfs simulation package github.com/ev3go/sisyphus. For historical reasons, the travis testing used the -a flag (since removed because of the issue described here). Since Go1.14, the standard runtime tests on travis passed,

<    1   2   3   4   5   6   7   >