Re: [go-nuts] Why Go allow function with unused arguments?

2022-01-30 Thread 'Dan Kortschak' via golang-nuts
On Sun, 2022-01-30 at 13:47 -0800, Sean Liao wrote: > By enforcing blanks, you'd lose the chance to name them something > useful to tell the reader why they're ignored. > eg: > // why are the last 2 args ignored?? > handleX = func(foo, bar, _, _ string) string { return foo + bar } >

Re: [go-nuts] Why Go allow function with unused arguments?

2022-01-30 Thread 'Dan Kortschak' via golang-nuts
On Sun, 2022-01-30 at 12:01 -0800, Kamil Ziemian wrote: > Hello, > > This is a question from ignorant in the meters of compilers and > mediocre Go users at best, so it may be stupid. > > I really like that in Go unused variable or import is compiler time > error. As such I wonder why function like

Re: [go-nuts] Generics: Whats the best way around limitation that methods can't be parameterized

2022-01-20 Thread 'Dan Kortschak' via golang-nuts
On Thu, 2022-01-20 at 19:05 -0800, Mandolyte wrote: > Or perhaps a hybrid, where the methods call generic functions... > > On Thursday, January 20, 2022 at 7:23:37 PM UTC-5 Ian Lance Taylor > wrote: > > On Thu, Jan 20, 2022 at 3:30 AM Travis Keep > > wrote: > > > > > > I am working on a

Re: [go-nuts] WIKI: Assert Libraries for Testing

2022-01-12 Thread 'Dan Kortschak' via golang-nuts
I have thoughts about the impact of assertion libraries in software engineering. I came from a background where they are commonplace into Go and in my earlier projects I used some the earlier iterations on them (go-check). While it's true that developers *can* use assertion libraries to provide

Re: [go-nuts] Convert a go.mod file into checked out dependencies

2022-01-12 Thread 'Dan Kortschak' via golang-nuts
While not a tool, there is code that can be bent to this in golang.org/x/pkgsite/internal/source. I used that to get repo information for a tool to obtain homepage and issue page links from Go executables[1]. You could easily extend that kind of approach to get the actual repo at the relevant

Re: [go-nuts] unit testing OS specific code

2022-01-04 Thread 'Dan Kortschak' via golang-nuts
On Tue, 2022-01-04 at 08:29 -0800, Brieuc Jeunhomme wrote: > Hi, > > I'm writing code that uses the golang.org/x/sys/windows/svc package. > This package compiles only for windows builds, for other GOOS values, > I get a build error. That's fair, but I'm wondering how to unit test > the code that

Re: [go-nuts] Float32 -> string --> Float32 round trip not possible for strconv.FormatFloat 'b' ?

2021-12-09 Thread 'Dan Kortschak' via golang-nuts
On Thu, 2021-12-09 at 17:22 -0800, Kurtis Rader wrote: > Note that the documentation for ParseFloat states: "ParseFloat > accepts decimal and hexadecimal floating-point number syntax." In > other words, it explicitly does not support the binary format emitted > by FormatFloat('b'). I don't know

Re: [go-nuts] src/errors/errors_test.go if err != err ?

2021-12-05 Thread 'Dan Kortschak' via golang-nuts
On Sun, 2021-12-05 at 13:24 -0800, arthurwil...@gmail.com wrote: > How is it possible for this test case to ever fail? > > // Same allocation should be equal to itself (not crash). > err := errors.New("jkl") > if err != err { > t.Errorf(`err != err`) > } >

Re: [go-nuts] Getting "cgo argument has Go pointer to Go pointer"

2021-11-15 Thread 'Dan Kortschak' via golang-nuts
On Mon, 2021-11-15 at 15:06 -0800, David Karr wrote: > > I'm pretty new to Go (many years in other languages). I'm trying to > use cgo to use a C library we're using. > > I have the following line of code, which is compiling (that's been > enough of a struggle): > > status =

Re: [go-nuts] Golang JPEG2000 implementation / Gauging community interest in supporting it?

2021-11-05 Thread 'Dan Kortschak' via golang-nuts
On Wed, 2021-11-03 at 18:50 -0700, Adam Koszek wrote: > Hello, > > We (Segmed.ai) are processing a lot of medical imaging data. It comes > to us in the form of PNG/JPG/DICOM files. 90% of it is uncompressed > or using a normal JPEG encoding, but around ~7% of it is encoded with > lossless JPEG

Re: [go-nuts] Re: Why Doesn't "len()" Work With Structs?

2021-10-24 Thread 'Dan Kortschak' via golang-nuts
On Sun, 2021-10-24 at 17:53 -0700, jlfo...@berkeley.edu wrote: > But this seems overly complicated. Sorry. That was a joke. You asked why you can't use len(); you can, by using it to it into create something that is indexable (and so a possible parameter for len()). > Plus, I don't see why this

Re: [go-nuts] Re: Why Doesn't "len()" Work With Structs?

2021-10-24 Thread 'Dan Kortschak' via golang-nuts
You can use len to determine the sizeof a struct. https://play.golang.org/p/f0x8p_04lP1 ;) On Sun, 2021-10-24 at 16:44 -0700, jlfo...@berkeley.edu wrote: > Thanks for the replies. > > I had been trying to translate the trick from C into Go where you can > find how many structures are in an

Re: [go-nuts] How to automatically embed module name from go.mod into executables?

2021-10-08 Thread 'Dan Kortschak' via golang-nuts
On Fri, 2021-10-08 at 16:36 -0700, Christian Stewart wrote: > Is there a way to /not/ have this information in the binary? > You can use the garble tool[1] to strip/garble things like this. $ cd golang.org/x/tools/cmd/stringer $ garble build . $ go version -m stringer stringer: unknown

Re: [go-nuts] Re: Questions about documentation of Go standard library

2021-10-08 Thread 'Dan Kortschak' via golang-nuts
On Fri, 2021-10-08 at 15:33 -0700, Kamil Ziemian wrote: > Hello, > > I now read documentation of "fmt" package and in "Format errors" ( > https://pkg.go.dev/fmt@go1.17.2#hdr-Format_errors) we have > Invalid or invalid use of argument index: %!(BADINDEX) > Printf("%*[2]d", 7):

Re: [go-nuts] Parse JSON case-sensitively

2021-09-24 Thread 'Dan Kortschak' via golang-nuts
On Fri, 2021-09-24 at 11:21 +0100, Ian Davis wrote: > This is not a correct interpretation. In your example the > unmarshaller reads the incoming json. The first key encountered is > "Name" and it matches exactly with the field named and tagged as Name > so that field is assigned the value. The

Re: [go-nuts] Parse JSON case-sensitively

2021-09-24 Thread 'Dan Kortschak' via golang-nuts
On Fri, 2021-09-24 at 11:21 +0100, Ian Davis wrote: > This is not a correct interpretation. In your example the > unmarshaller reads the incoming json. The first key encountered is > "Name" and it matches exactly with the field named and tagged as Name > so that field is assigned the value. The

Re: [go-nuts] Parse JSON case-sensitively

2021-09-24 Thread 'Dan Kortschak' via golang-nuts
On Fri, 2021-09-24 at 10:22 +0100, Ian Davis wrote: > I was responding to your statement that it doesn't appear to use > exact match in preference. It does, as the example I gave > demonstrated. It's not about guarding case. I'll clarify. In the example I posted

Re: [go-nuts] Parse JSON case-sensitively

2021-09-24 Thread 'Dan Kortschak' via golang-nuts
On Fri, 2021-09-24 at 09:55 +0100, Ian Davis wrote: > On Fri, 24 Sep 2021, at 9:36 AM, 'Dan Kortschak' via golang-nuts > wrote: > > On Fri, 2021-09-24 at 01:03 -0700, Brian Candler wrote: > > > On Friday, 24 September 2021 at 08:25:31 UTC+1 Brian Candler > > > wrote:

Re: [go-nuts] Parse JSON case-sensitively

2021-09-24 Thread 'Dan Kortschak' via golang-nuts
On Fri, 2021-09-24 at 01:03 -0700, Brian Candler wrote: > On Friday, 24 September 2021 at 08:25:31 UTC+1 Brian Candler wrote: > > The documentation says it prefers exact match over case- > > insensitive, but example 3 contradicts that. It seems to be last- > > match that wins. > > > > > > I

Re: [go-nuts] how atomic instruction work?

2021-09-21 Thread 'Dan Kortschak' via golang-nuts
Also, https://research.swtch.com/mm. On Tue, 2021-09-21 at 16:22 -0500, robert engels wrote: > This may be of interest to you: > https://github.com/golang/go/issues/5045 > > > On Sep 21, 2021, at 4:17 PM, Ian Lance Taylor > > wrote: > > > > On Tue, Sep 21, 2021 at 12:54 PM xie cui > > wrote: >

Re: [go-nuts] slices grow at 25% after 1024 but why 1024?

2021-09-05 Thread 'Dan Kortschak' via golang-nuts
On Sun, 2021-09-05 at 13:09 +0200, 'Axel Wagner' via golang-nuts wrote: > This sounds interesting, but I don't understand it. Would you be > willing to expand on this? It's a consequence of the sum of successive powers of two. To have reached an allocation of 2^n slots assuming a doubling n times

Re: [go-nuts] Re: slices grow at 25% after 1024 but why 1024?

2021-09-05 Thread 'Dan Kortschak' via golang-nuts
On Sun, 2021-09-05 at 03:51 -0700, Brian Candler wrote: > I'm not sure you're clear about what "monotonically increasing" > means. > > Are you saying that there are some cases where append() results in > the allocated size of a slice *shrinking*? If so, please > demonstrate. I think he means

Re: [go-nuts] slices grow at 25% after 1024 but why 1024?

2021-09-05 Thread 'Dan Kortschak' via golang-nuts
On Sun, 2021-09-05 at 08:15 +0200, 'Axel Wagner' via golang-nuts wrote: > Whether that factor is 2 or 1.25 doesn't matter. It's just a bit of > an optimization to make it 2 for small values - it doesn't terribly > matter what's "small" for this heuristic. There is a reason for choosing a factor

Re: [go-nuts] Re: slices grow at 25% after 1024 but why 1024?

2021-09-04 Thread 'Dan Kortschak' via golang-nuts
This is what you're describing, right? https://play.golang.org/p/RJbEkmFsPKM The code that does this is here https://github.com/golang/go/blob/9133245be7365c23fcd60e3bb60ebb614970cdab/src/runtime/slice.go#L183-L242 . Note that there are cap adjustments to optimise block sizes and alignments. This

Re: [go-nuts] Two consecutive reads from a buffered channel results in deadlock

2021-09-04 Thread 'Dan Kortschak' via golang-nuts
What would you expect to happen here? A chan that has had one item sent and then one item received has no items on it, so a receive must wait until another item is sent. On Sat, 2021-09-04 at 17:55 -0700, Michael Dwyer wrote: > I encountered a deadlock when reading from a buffered channel. > The

Re: [go-nuts] Using a local copy of an external package?

2021-08-26 Thread 'Dan Kortschak' via golang-nuts
On Thu, 2021-08-26 at 18:21 -0400, Paul S. R. Chisholm wrote: > Hypothetical example: Say I'm writing an application that > uses "rsc.io/quote" and I discover a bug in that package that breaks > my software. I would of course clone the quote repository, add a test > that demonstrates the bug, fix

[go-nuts] no plan9obj.ErrNoSymbols

2021-08-26 Thread 'Dan Kortschak' via golang-nuts
The elf package provide a sentinel error, ErrNoSymbols for the case that Symbols or DynamicSymbols cannot return a symbol list because the section is empty[1]. The same situation is handled in plan9obj by returning a new error for this case[2-3]. For PE/Mach-O there is no issue since access to the

Re: [go-nuts] Source links on cs.opensource.google are slow (links for stdlib on pkg.go.dev)

2021-08-25 Thread 'Dan Kortschak' via golang-nuts
On Wed, 2021-08-25 at 18:11 -0700, ben...@gmail.com wrote: > With the switch to pkg.go.dev (which in itself I quite like after > getting used to it), the view-source links also changed from the > golang.org source viewer, which was fast, to cs.opensource.google, > which is rather slow. > > For

Re: [go-nuts] convert image to pure black and white

2021-08-15 Thread 'Dan Kortschak' via golang-nuts
On Mon, 2021-08-16 at 09:22 +0700, Rijal Asep Nugroho wrote: > I was browsing how to make a golang code to convert an image to pure > black and white, but didn't find a suitable one, only got how to > convert the image to grayscale. > Can anyone help? thank you. If you do a greyscale conversion

Re: [go-nuts] The behavior of the function variable which points to the struct method

2021-08-10 Thread 'Dan Kortschak' via golang-nuts
On Tue, 2021-08-10 at 15:54 -0700, E Z wrote: > I quite agree with your above conclusion, and the test results also > prove it. That seems to be the way it's designed right now, but what > I find a little hard to understand here is why it's not designed as > "The pointer to function assignment

Re: [go-nuts] The behavior of the function variable which points to the struct method

2021-08-10 Thread 'Dan Kortschak' via golang-nuts
On Tue, 2021-08-10 at 14:50 -0700, E Z wrote: > It works when I changed the code as your suggested. That's great, > thanks. > > And I'm still a little confused here, you know when we use the struct > method directly, it is only when the function is called that the type > of receiver determines

Re: [go-nuts] doc comment for io.Closer

2021-07-29 Thread 'Dan Kortschak' via golang-nuts
On Thu, 2021-07-29 at 11:45 -0700, Ian Lance Taylor wrote: > > Should this be "unspecified" rather than "undefined"? > > The general concern here is that if there is something like a file > descriptor involved, and if the Close method doesn't take special > protection to avoid problems with

[go-nuts] doc comment for io.Closer

2021-07-29 Thread 'Dan Kortschak' via golang-nuts
I just noticed today that the io.Closer docs say that "The behavior of Close after the first call is undefined. Specific implementations may document their own behavior". Should this be "unspecified" rather than "undefined"? Dan -- You received this message because you are subscribed to the

Re: [go-nuts] Understanding benchstat's output

2021-07-27 Thread 'Dan Kortschak' via golang-nuts
On Tue, 2021-07-27 at 20:55 -0700, Tong Sun wrote: > Hi, > > I'm trying to understand the benchstat's output. > The benchstat that I have is fresh from golang.org/x/perf/cmd/, > installed hours ago. > > This is understandable: > > nameold time/opnew time/opdelta > FormatEmoji-2

Re: [go-nuts] how to purge invalid tags from GOPROXY?

2021-06-30 Thread 'Dan Kortschak' via golang-nuts
On Wed, 2021-06-30 at 15:45 -0700, 'Jay Conrod' via golang-nuts wrote: > Hi Sebastien, once a version is in proxy.golang.org, it usually can't > be removed. This is important to ensure that builds continue working > when a repository disappears upstream. > > You may want to publish a new version

Re: [go-nuts] Data race problem with mutex protected maps

2021-06-26 Thread 'Dan Kortschak' via golang-nuts
On Sat, 2021-06-26 at 20:44 -0700, Ian Lance Taylor wrote: > Looks like you have multiple SearchResults values that refer to the > same map. Shouldn't that result in a panic, even without -race? Dan -- You received this message because you are subscribed to the Google Groups "golang-nuts"

Re: [go-nuts] Data race problem with mutex protected maps

2021-06-26 Thread 'Dan Kortschak' via golang-nuts
On Sat, 2021-06-26 at 23:26 +0100, Rory Campbell-Lange wrote: > I'm trying to work out why I have a data race problem (on go 1.15 and > 1.16). > > *SearchResults.Set is called from several goroutines. I am trying to > avoid concurrent access to its two maps using a mutex, but this isn't > working.

Re: [go-nuts] What is the point of gzip Reader.Close?

2021-06-22 Thread 'Dan Kortschak' via golang-nuts
On Tue, 2021-06-22 at 12:45 -0500, Steven Penny wrote: > Thanks for the help, but I found a much simpler example: > > https://play.golang.org/p/EcitH-85X6S Yes, trivial examples also exist. -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To

Re: [go-nuts] What is the point of gzip Reader.Close?

2021-06-21 Thread 'Dan Kortschak' via golang-nuts
On Mon, 2021-06-21 at 18:22 -0500, Steven Penny wrote: > I am not questioning anyones knowledge, I am just asking for a > demonstration, rather than "do it because we said so". https://play.golang.org/p/gwDnxVSQEM4 -- You received this message because you are subscribed to the Google Groups

Re: [go-nuts] What is the point of gzip Reader.Close?

2021-06-21 Thread 'Dan Kortschak' via golang-nuts
On Mon, 2021-06-21 at 17:57 -0500, Steven Penny wrote: > > No, I gave a clear path that would lead to a case of a non-detected > > error when Close is not called. > > > > This seems like a really odd hill to die on, but it's your choice I > > guess. > > You calling "go look through 3200 lines of

Re: [go-nuts] What is the point of gzip Reader.Close?

2021-06-21 Thread 'Dan Kortschak' via golang-nuts
On Mon, 2021-06-21 at 17:44 -0500, Steven Penny wrote: > and none has been able to provide a simple program that demonstrate a > problem that could arise from not closing gzip reader. No, I gave a clear path that would lead to a case of a non-detected error when Close is not called. This seems

Re: [go-nuts] What is the point of gzip Reader.Close?

2021-06-21 Thread 'Dan Kortschak' via golang-nuts
On Mon, 2021-06-21 at 17:30 -0500, Steven Penny wrote: > > No other compress reader even has a Close method, so I think Im > > fine: > > - https://golang.org/pkg/compress/bzip2 > - https://golang.org/pkg/compress/flate > - https://golang.org/pkg/compress/lzw > -

Re: [go-nuts] What is the point of gzip Reader.Close?

2021-06-21 Thread 'Dan Kortschak' via golang-nuts
On Mon, 2021-06-21 at 16:53 -0500, Steven Penny wrote: > > Again, the idiom is, if you get an `io.Closer`, `Close` should be > > called once > > you're done with it. > > Thanks for the responses, but I am not convinced. Other than "its > just good > practice", I havent seen a single concrete

Re: [go-nuts] Knowing from documentation whether an interface is holding a pointer or a struct?

2021-06-08 Thread 'Dan Kortschak' via golang-nuts
On Tue, 2021-06-08 at 07:57 -0500, robert engels wrote: > The following code is works fine from the developers perspective: > > https://play.golang.org/p/gC1XsSLvovM > > The developer says, oh cool, I see this great new 3P library that > does background logging - I want to use that instead. Hey, I

Re: [go-nuts] Knowing from documentation whether an interface is holding a pointer or a struct?

2021-06-06 Thread 'Dan Kortschak' via golang-nuts
On Sun, 2021-06-06 at 03:17 -0700, Brian Candler wrote: > When you assign a regular (non-pointer) value to an interface > variable, it does take a copy of that value: > https://play.golang.org/p/XyBREDL4BGw It depends on whether it's safe to leave uncopied or not. You can see this here

Re: [go-nuts] Why the limit on regex repeat is 1000?

2021-06-06 Thread 'Dan Kortschak' via golang-nuts
On Sun, 2021-06-06 at 18:14 +1000, Rob Pike wrote: > You are using a steamroller to press a shirt. Tomi Ungerer has already published this approach. https://kotonoha-books.ocnk.net/data/kotonoha-books/product/20160619_70ddf5.JPG -- You received this message because you are subscribed to the

Re: [go-nuts] SetMapIndex() equivalent for slice/array

2021-06-04 Thread 'Dan Kortschak' via golang-nuts
On Fri, 2021-06-04 at 20:29 -0700, Deiter wrote: > The reflect package provides the SetMapIndex method for updating > elements in a map that are represented by a reflect.Value type, but I > don’t see an equivalent for array/slice. > The sample app (link provided below) includes an example of map >

Re: [go-nuts] How can I check error types of gRPC calls?

2021-05-15 Thread 'Dan Kortschak' via golang-nuts
On Sat, 2021-05-15 at 04:47 -0700, cpu...@gmail.com wrote: > In my local code, I'm using things like > > if errors.Is(err, api.ErrMustRetry) { ... } > > How would I achieve the same on errors returned by the gRCP > interface? I've noticed these are wrapped: > > rpc error: code = Unknown desc =

Re: [go-nuts] rationale for math.Max(1, math.NaN()) => math.NaN()?

2021-04-27 Thread 'Dan Kortschak' via golang-nuts
On Mon, 2021-04-26 at 23:28 -0700, christoph...@gmail.com wrote: > It seam that C is wrong on this one and Go is right. The rationale is > that a NaN must propagate through operations so that we can detect > problems (avoid silent NaNs). See https://en.wikipedia.org/wiki/NaN > > Thus any operation

[go-nuts] rationale for math.Max(1, math.NaN()) => math.NaN()?

2021-04-22 Thread 'Dan Kortschak' via golang-nuts
This is not something that I've thought about before, but the behaviour of math.Max when only one of its arguments is NaN does not agree with the C convention or the IEEE-754 standard behaviour for max (5.3.1 p19 "maxNum(x, y) is the canonicalized number y if x #include void main() {

Re: [go-nuts] Re: help with the Google Pub/Sub Go client API

2021-04-19 Thread 'Dan Kortschak' via golang-nuts
Comments in-line. On Mon, 2021-04-19 at 15:08 -0700, 'hong...@google.com' via golang-nuts wrote: > Ah, glad your issue was resolved. I did want to point out one thing: > > > 2. The topic was obtained in the subscriber using new topic > creation > > `client.CreateTopic(ctx, topic)` rather than

Re: [go-nuts] Re: help with the Google Pub/Sub Go client API

2021-04-19 Thread 'Dan Kortschak' via golang-nuts
On Mon, 2021-04-19 at 10:37 -0700, 'hong...@google.com' via golang-nuts wrote: > Is it possible for you to paste your yaml config file? At first > glance, nothing seems to be out of the ordinary, but I'd like to try > with the same configuration that you have to see if I missed > anything.

[go-nuts] help with the Google Pub/Sub Go client API

2021-04-15 Thread 'Dan Kortschak' via golang-nuts
I am trying to set up a toy to understand Google's Pub/Sub service Go client API. I have had no trouble with publishing and have a local emulator for the Google Scheduler service to build against, but I am having a lot of trouble getting subscriptions to work. I am able get a subscription to work

Re: [go-nuts] go text://protocol client?

2021-04-09 Thread 'Dan Kortschak' via golang-nuts
On Fri, 2021-04-09 at 17:01 +0200, 'Petite Abeille' via golang-nuts wrote: > [1] https://textprotocol.org That's an extraordinarily and unnecessarily obtuse document. -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this

Re: [go-nuts] Re: Parallel Matrix Multiplication

2021-03-25 Thread 'Dan Kortschak' via golang-nuts
On Thu, 2021-03-25 at 14:20 -0400, jasm...@gmail.com wrote: > Blast from the past so it's hard to be sure, but I think that was how > many rows or columns to pick for parallel sub matrices to multiply. > > On Thu, Mar 25, 2021, 1:17 PM Gabriel Pcklub < > gabrielpckl...@gmail.com> wrote: > > Hello,

Re: [go-nuts] Oopses in standard-library documentation

2021-03-24 Thread 'Dan Kortschak' via golang-nuts
On Wed, 2021-03-24 at 18:31 -0700, Scott Pakin wrote: > I just noticed that some of the package comments in the standard > library are coming from the wrong source file. Here are two examples > from a golang.org/pkg/ screenshot: > > > In the case of the former, src/os/exec/read3.go appears to be

Re: [go-nuts] Thanks

2021-03-24 Thread 'Dan Kortschak' via golang-nuts
On Wed, 2021-03-24 at 22:09 +, alex breadman wrote: > Let's keep divisive political BS away from this lovely project. > > Glad to see the political header removed from the website, at least > on mobile. > > All lives matter. This too is a political statement. -- You received this message

Re: [go-nuts] Re: [ANN] New german translations

2021-03-16 Thread 'Dan Kortschak' via golang-nuts
On Tue, 2021-03-16 at 03:10 -0700, Haddock wrote: > Anyhow, if I hear how young people are talking nowadays, it makes me > sick. Die Funktion wurde "gecalled" und die Exception "gethrown". > Sometimes I fear the next generation will not have learned to watch > what their mind is doing. I might be

Re: [go-nuts] [ANN] MQTT烙

2021-03-14 Thread 'Dan Kortschak' via golang-nuts
On Sun, 2021-03-14 at 15:08 -0700, Pascal de Kloe wrote: > > Did you consider using context.Context rather than quit channels? > > Applying a context.Context pretty much implies using a quit channel. > Done is the only way to receive an expiry signal. > > I just don't want to lock code into using

[go-nuts] addressing the issue of correlating built in structured types in generic code: float/complex

2021-03-14 Thread 'Dan Kortschak' via golang-nuts
Now that a proposal for an approach to generics has been approved[1], it seems like a good time to again[2] raise the issue of how to be able to write code that has correlated types where types are structured but built-in, and so fields are not available to examine. The only case of this in the

Re: [go-nuts] [ANN] MQTT烙

2021-03-14 Thread 'Dan Kortschak' via golang-nuts
On Sun, 2021-03-14 at 10:41 -0700, Pascal de Kloe wrote: > New MQTT client library + command line tool available. > > https://github.com/pascaldekloe/mqtt > > Comments are welcome. Did you consider using context.Context rather than quit channels? -- You received this message because you are

Re: [go-nuts] What does `go install path/to/main.go` do with GO111MODULE=on?

2021-03-10 Thread 'Dan Kortschak' via golang-nuts
On Wed, 2021-03-10 at 15:20 -0800, Matt Mueller wrote: > I'm assuming this is by design, but it feels to me like go install > ./cmd/app/main.go silently failing is a bug. > > Is this worth opening an issue for? If it's a bug it's an error reporting bug. The go install command is documented to

Re: [go-nuts] go install, replace directive any ongoing discussions?

2021-03-07 Thread 'Dan Kortschak' via golang-nuts
On Sun, 2021-03-07 at 07:57 +, Paul Jolly wrote: > Erroring on replace directives is an intentional decision for now: > https://github.com/golang/go/issues/40276#issue-659471259 > > But might be relaxed in the future: > > > Parts of this proposal are more strict than is technically > >

Re: [go-nuts] Contrary to popular opinion...

2021-02-28 Thread 'Dan Kortschak' via golang-nuts
On Sun, 2021-02-28 at 10:11 -0800, Bob Alexander wrote: > I never have understood the *serious* hatred of Python's "indentation > as syntax" approach. I've used lots of bracketed and begin/end > languages (C/C++, Algol & relatives, Ruby, and most other programming > languages), and when I write

Re: [go-nuts] Contrary to popular opinion...

2021-02-28 Thread 'Dan Kortschak' via golang-nuts
On Sun, 2021-02-28 at 09:23 +0100, Jan Mercl wrote: > I meant, for example, in regexp notation, ` *` vs `\n *` between a > function signature and the opening brace of the function body. Ah, yes. > This assumes newline is a whitespace. Most programming languages > agree, but humans may not. With

Re: [go-nuts] Contrary to popular opinion...

2021-02-28 Thread 'Dan Kortschak' via golang-nuts
On Sun, 2021-02-28 at 08:40 +0100, Jan Mercl wrote: > Actually Go has that problem as well, just a thousand times smaller. I'm curious where the meaningful whitespace is in Go (for amounts differences in number greater than 1). > FTR, I also think Python's approach to white space is a failure.

Re: [go-nuts] big.Float.Cmp does not work as expected

2021-02-16 Thread 'Dan Kortschak' via golang-nuts
On Wed, 2021-02-17 at 02:33 +0530, Santhosh T wrote: > is there java's BigDecimal equivalent in golang ? There is, for example https://github.com/shopspring/decimal. But you should ask yourself why you need this. -- You received this message because you are subscribed to the Google Groups

Re: [go-nuts] big.Float.Cmp does not work as expected

2021-02-14 Thread 'Dan Kortschak' via golang-nuts
You can set your precision arbitrarily high, but you will still find a point at which there are non-zero decimal digits. https://play.golang.org/p/JYcAvXQPfeO 123.4 cannot be represented in binary with a finite number of bits. On Sun, 2021-02-14 at 13:33 -0800, Santhosh Kumar T wrote: > now I

Re: [go-nuts] big.Float.Cmp does not work as expected

2021-02-14 Thread 'Dan Kortschak' via golang-nuts
On Sun, 2021-02-14 at 13:19 -0800, Santhosh Kumar T wrote: > When I print both values, they print exactly same. so I am assuming > no precision lost for this specific example 123.4. > but still Cmp returns non-zero. This is not a good assumption to make, and is refuted by the result of Cmp.

Re: [go-nuts] Code style in golang compiler

2021-02-08 Thread 'Dan Kortschak' via golang-nuts
On Mon, 2021-02-08 at 19:09 -0800, messi...@gmail.com wrote: > Hi, > > I'm reading the go compiler source code and found the following code > style in several places: > > > > Is there some special reasons to group n,m,p to a local struct? > > Why don't we just init n the following way:

Re: [go-nuts] R.I.P. Michael Jones

2021-02-04 Thread 'Dan Kortschak' via golang-nuts
On Fri, 2021-02-05 at 00:12 +0100, Jan Mercl wrote: > https://www.geospatialworld.net/blogs/goodbye-michael-jones-the-man-who-gave-the-power-of-maps-in-our-hands/ Thank you for letting us know, Jan. He will be missed. -- You received this message because you are subscribed to the Google

Re: [go-nuts] How to improve the parallelism of go routine?

2021-02-02 Thread 'Dan Kortschak' via golang-nuts
On Mon, 2021-02-01 at 23:48 -0800, 颜文泽 wrote: > This is my code: > 2021-02-02 15-45-01 的屏幕截图.png Please don't post code as images. -- 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

Re: [go-nuts] Interface arguments to generic functions

2021-01-19 Thread 'Dan Kortschak' via golang-nuts
On Tue, 2021-01-19 at 21:38 -0800, Ian Lance Taylor wrote: > On Tue, Jan 19, 2021 at 8:41 PM Dan Kortschak > wrote: > > > > Would that work for non-comparable types? Say the T has an > > underlying > > []int type, then the comparison is not against nil and y

Re: [go-nuts] package is not in goroot

2021-01-19 Thread 'Dan Kortschak' via golang-nuts
On Tue, 2021-01-19 at 16:08 -0800, Alexander Mills wrote: > I have never seen the dot needed, I have used plenty of packages that > are in GOPATH but not GOROOT https://go.googlesource.com/go/+/go1.15.6/src/cmd/go/internal/search/search.go#542 This is why it is saying that it's expecting it to

Re: [go-nuts] Generics syntax suggestion

2021-01-19 Thread 'Dan Kortschak' via golang-nuts
On Tue, 2021-01-19 at 22:44 +, Kevin Chadwick wrote: > On January 19, 2021 9:13:55 PM UTC, Levieux Michel < > mlevieu...@gmail.com> wrote: > > I think the question was: "given your proposal here, I can write > > func > > (string | []byte in1, string | []byte in2) which enforces that in1 > >

Re: [go-nuts] package is not in goroot

2021-01-19 Thread 'Dan Kortschak' via golang-nuts
On Tue, 2021-01-19 at 13:54 -0800, Alexander Mills wrote: > i am getting this weird error message: > > package twitch/go-scripts/dynamo-creators-to-s3/lib is not in GOROOT > (/usr/local/Cellar/go/1.15.6/libexec/src/twitch/go-scripts/dynamo- > creators-to-s3/lib) > > my GOPATH=$PWD/scripts/go >

Re: [go-nuts] Generics syntax suggestion

2021-01-19 Thread 'Dan Kortschak' via golang-nuts
On Tue, 2021-01-19 at 21:09 +, Kevin Chadwick wrote: > On January 19, 2021 8:22:01 PM UTC, 'Dan Kortschak' via golang-nuts < > golang-nuts@googlegroups.com> wrote: > > On Tue, 2021-01-19 at 20:01 +, Kevin Chadwick wrote: > > > I was inquiring about the po

Re: [go-nuts] Generics syntax suggestion

2021-01-19 Thread 'Dan Kortschak' via golang-nuts
On Tue, 2021-01-19 at 20:01 +, Kevin Chadwick wrote: > I was inquiring about the possibility of no identifiers or > abstraction but simply like Gos non generic functions (possibly > reversed if needed). Using type OR type. > > func (String | []byte firstInput, myType | publicKey >

Re: [go-nuts] Re: Generics - please provide real life problems

2020-12-25 Thread 'Dan Kortschak' via golang-nuts
On Fri, 2020-12-25 at 18:11 +0100, Martin Hanson wrote: > > What are you on about!? This is my second post on this list, and even > though both are about > generics, they are adequately different to be kept about otherwise it > becomes a big mess. Some mailers do not properly handle headers

Re: [go-nuts] Obtaining an efficient hash for Go values

2020-12-24 Thread 'Dan Kortschak' via golang-nuts
You can also use the internal map implementation and make us of the runtime's map iterator. This is relatively straightforward at the cost of vigilance for changes in the runtime. Here is an example (note that yo need a .S file as well to get the go:linkname magic to work).

Re: [go-nuts] Generics - please provide real life problems

2020-12-24 Thread 'Dan Kortschak' via golang-nuts
I agree. A lot of Gonum code would be greatly simplified with the availability of generics, particularly the linear algebra part. The graph packages would be richer and we could do more things with tensor-like operations. On Wed, 2020-12-23 at 23:54 -0800, Marcin Romaszewicz wrote: > Those are

Re: [go-nuts] printing an empty slice with fmt.Printf()

2020-12-18 Thread 'Dan Kortschak' via golang-nuts
I think that's the question. Here's a simpler example, https://play.golang.org/p/9Kv3PhlM-OF That is, is 00 an expected %02x representation of a zero-length byte slice? The answer to that is yes; the 02 forces leading zeros. The %x verb essentially renders bit strings as hex, so a zero-length

Re: [go-nuts] using the xml package with data with complex name spacing

2020-12-14 Thread 'Dan Kortschak' via golang-nuts
On Mon, 2020-12-14 at 13:53 +, Sam Whited wrote: > In the example you provided it is working as expected. The element > you're unmarshaling is in the " > http://www.w3.org/1999/02/22-rdf-syntax-ns#; namespace (it has an > "rdf" > prefix) but the thing you're unmarshaling it into expects >

[go-nuts] using the xml package with data with complex name spacing

2020-12-13 Thread 'Dan Kortschak' via golang-nuts
I'm needing to consume some XML which has a namespace identifier reused. http://purl.obolibrary.org/obo/go/subsets/goslim_yeast.owl#; xml:base="http://purl.obolibrary.org/obo/go/subsets/goslim_yeast.owl; xmlns:go="http://purl.obolibrary.org/obo/go#;

Re: [go-nuts] Online service to run Go code with Go modules support

2020-11-20 Thread 'Dan Kortschak' via golang-nuts
That's not an error. https://github.com/rsc/quote/blob/754f68430672776c84704e2d10209a6ec700cd64/quote.go#L22-L24 On Fri, 2020-11-20 at 17:49 -0800, Alexey Melezhik wrote: > Thanks. I receive " Don't communicate by sharing memory, share memory > by communicating. " error (?) when run the example

Re: [go-nuts] Online service to run Go code with Go modules support

2020-11-20 Thread 'Dan Kortschak' via golang-nuts
It does, but it depends on how big of a dependency set is imported due to timeout. The example below does work. https://play.golang.org/p/WL-OhWYsx68 On Fri, 2020-11-20 at 22:45 +, Paul Jolly wrote: > Hi, > > > Hi go devs. I am thinking about brining up a service that would > > execute Go

Re: [go-nuts] Go modules in gihub repos

2020-11-19 Thread 'Dan Kortschak' via golang-nuts
Reference: https://golang.org/ref/mod#vcs-version > If a module is defined in a subdirectory within the repository, that > is, the module subdirectory portion of the module path is not empty, > then each tag name must be prefixed with the module subdirectory, > followed by a slash. For example,

Re: [go-nuts] Go modules in gihub repos

2020-11-19 Thread 'Dan Kortschak' via golang-nuts
You should tag the version with the path to the module root: for example path/from/root/v1.2.3 On Thu, 2020-11-19 at 18:58 -0800, Victor Denisov wrote: > Hi, > > I've recently encountered an interesting behavior of go modules. > I have a library in a repository on github. The go.mod file for

Re: [go-nuts] Let Go also support manual memory management, a good or bad idea?

2020-11-15 Thread 'Dan Kortschak' via golang-nuts
This can already be done using C.malloc and C.free. You won't have access to map types using a Cgo allocator, but then you wouldn't if you had to allocate using built-ins either. On Sun, 2020-11-15 at 17:37 -0800, tapi...@gmail.com wrote: > For example, by adding two new built-in functions: alloc

Re: [go-nuts] detecting cyclic references

2020-11-14 Thread 'Dan Kortschak' via golang-nuts
Or github.com/kortschak/utter . This package does an arguably better job at dealing with self- referencing structures. On Sat, 2020-11-14 at 03:52 -0800, twp...@gmail.com wrote: > > My use case is that I want to pretty print in-memory objects for > debug purposes during testing, and one of the

Re: [go-nuts] Re: use same for/range code on a hash map but it has different result

2020-11-10 Thread 'Dan Kortschak' via golang-nuts
On Tue, 2020-11-10 at 22:17 -0800, Kurtis Rader wrote: > Jeebus. H. Christ! Yes, you can "safely" mutate a map while iterating > over it. In as much as doing so will not result in a panic; although, > I'm not convinced that is true. The point of the O.P. is that they > expect the map mutation to

Re: [go-nuts] Re: use same for/range code on a hash map but it has different result

2020-11-10 Thread 'Dan Kortschak' via golang-nuts
On Wed, 2020-11-11 at 06:02 +, 'Dan Kortschak' via golang-nuts wrote: > So long as you take into account these caveats, mutating a map during > a range will not corrupt the map or other data structure, and will > cause your application to crash. s/will cause/will not cause/ -- You

Re: [go-nuts] Re: use same for/range code on a hash map but it has different result

2020-11-10 Thread 'Dan Kortschak' via golang-nuts
On Tue, 2020-11-10 at 20:28 -0800, 'Kilos' via golang-nuts wrote: > You cannot safely mutate a Go map while iterating over it with the > `range` operator. This is not true, depending on your definition of "safely". See https://golang.org/ref/spec#For_statements "For statements with range

Re: [go-nuts] Re: use same for/range code on a hash map but it has different result

2020-11-10 Thread 'Dan Kortschak' via golang-nuts
On Tue, 2020-11-10 at 19:08 -0800, 'Kilos' via golang-nuts wrote: > Thanks for reply, but I want to know the underlying reason about it, > I think the reason is in how the runtime functions works. The direct cause is that the hash function used for the map implementation is seeded from the system

Re: [go-nuts] go list "go:generate" files

2020-11-10 Thread 'Dan Kortschak' via golang-nuts
//go:generate is not limited to dependency on Go source files, so this is not possible in the general case. On Tue, 2020-11-10 at 01:05 -0800, gta wrote: > Thanks for the reply, > yes I know I can grep for those files, but I was hoping that go list > could give me the files in the reverse

Re: [go-nuts] strconv.ParseFloat panic

2020-11-06 Thread 'Dan Kortschak' via golang-nuts
OK, so you're not using Cgo, that leaves some other unsafe use, a data race or unlikely some weird compiler bug. I'd start looking in api.handleDPriceRange to see where the string input to strconv.ParseFloat is being constructed. On Fri, 2020-11-06 at 01:10 -0800, blade...@gmail.com wrote: > go

Re: [go-nuts] strconv.ParseFloat panic

2020-11-06 Thread 'Dan Kortschak' via golang-nuts
The full panic would help, but somehow you have a string with a nil pointer that is 4 bytes long. Where is the string generated? Are you using Cgo? Have you run with the race detector? Also, what version of Go are you using? On Fri, 2020-11-06 at 00:00 -0800, blade...@gmail.com wrote: > i check

Re: [go-nuts] Syntactic Sugar Idea for Go 2.0: until/unless, and postfix conditionals

2020-11-02 Thread 'Dan Kortschak' via golang-nuts
There are two parts. The worse part is the negative conditional (unless), which has the problem that humans are bad at negations; nearly always when there is a complex condition with an "unless", it needs to be mentally refactored into an "if !" (when working through other people's bugs, I

Re: [go-nuts] Syntactic Sugar Idea for Go 2.0: until/unless, and postfix conditionals

2020-11-02 Thread 'Dan Kortschak' via golang-nuts
My first professional programming language was Perl, decades later I still wake up in a sweat thinking about post-fix conditionals and the 'unless' conditional. Please no. On Mon, 2020-11-02 at 14:26 -0800, Jeffrey Paul wrote: > Hello Gophers, > > There's two tiny pieces of syntactic sugar I

Re: [go-nuts] Running "go test" modifies go.mod & go.sum

2020-11-01 Thread 'Dan Kortschak' via golang-nuts
Ah, it just clicked. You're indirectly using go/packages, which will (unless configured not to), cause changes to the go.mod and go.sum file. This configuration happens for this by adding "-mod=readonly" to packages.Config.BuildFlags (I think). But this isn't exposed via the go/analysis API (the

<    1   2   3   4   5   6   7   >