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. Thanks,

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 gett

[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() { prin

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

2021-04-26 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

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

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

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 https://pla

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

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 > - https://golang.org/pkg/compress/zlib

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 li

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 Go

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

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 uns

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

Re: [go-nuts] Why isn't there "number plus" postfix syntax for more than or equal?

2020-04-23 Thread 'Dan Kortschak' via golang-nuts
I look forward to the addition of the definition of "in a handwavy sense" to the spec. On Thu, 2020-04-23 at 11:41 -0700, Michael Jones wrote: > You could extend the notation: > > If r 13+- { > // if r is close to 13, in a handwavy sense > : > } > > On Thu, Apr 23, 2020 at 9:43 AM Ian Lance

Re: [go-nuts] Should an assignment from int to a type based on int succeed?

2020-05-09 Thread 'Dan Kortschak' via golang-nuts
In https://golang.org/ref/spec#Types a Type is defined in terms of a TypeName a TypeLit or a (Type). A TypeName is what makes a type a named type. This is defined as either an identifier or a qualified identifier. For the discussion here we can ignore the latter. An identifier contains letters and

Re: [go-nuts] Should an assignment from int to a type based on int succeed?

2020-05-09 Thread 'Dan Kortschak' via golang-nuts
Yes, sorry. Eight years of habit is hard to break. I think I agree with you; a small bit of text in https://golang.org/ref/spec#Type_definitions linking to https://golang.org/ref/spec#Predeclared_identifiers and saying that there exist already defined types may ease this, or the suggestion you ha

Re: [go-nuts] Nondeterministic Behavior of for Loop Ranging Over a map

2020-05-26 Thread 'Dan Kortschak' via golang-nuts
On Tue, 2020-05-26 at 16:26 +1000, Jesse McNelis wrote: > On Tue, May 26, 2020 at 3:37 PM Paul Jolly wrote: > > > Why the output of this code is nondeterministic? > > > > See https://golang.org/ref/spec#For_statements, specifically the > > "For > > statements with range clause" subheading, specif

Re: [go-nuts] net.go ok function's c != nil check right ?

2020-06-03 Thread 'Dan Kortschak' via golang-nuts
It's perfectly valid to call a method on a nil receiver, so long at the nil receiver is not dereferenced. https://play.golang.org/p/Z-zXlj0-eVy On Wed, 2020-06-03 at 00:03 -0700, apmat...@gmail.com wrote: > Read function at net.go is like this: > > func (c *conn) Read(b []byte) (int, error) { >

Re: [go-nuts] compress/bzip2:Why is there only a decompression function, no compression function.

2020-06-08 Thread 'Dan Kortschak' via golang-nuts
Also see https://godoc.org/github.com/dsnet/compress/bzip2 and https://github.com/dsnet/compress/issues/58 On Mon, 2020-06-08 at 13:14 -0400, Sam Whited wrote: > See: https://github.com/golang/go/issues/4828 > > On Mon, Jun 8, 2020, at 05:09, lziqia...@gmail.com wrote: > > Why is there no bzip2

Re: [go-nuts] compress/bzip2:Why is there only a decompression function, no compression function.

2020-06-08 Thread 'Dan Kortschak' via golang-nuts
bzip2 compression is not trivial so making sure the review catches any issues will take time. Finding people with the relevant expertise and the time to do the review is not necessarily easy. Note that you can use the dsnet package. On Mon, 2020-06-08 at 18:55 -0700, lziqia...@gmail.com wrote: >

Re: [go-nuts] political fundraising on golang.org!

2020-06-14 Thread 'Dan Kortschak' via golang-nuts
In the context of a sufficiently large collection of people all actions are political to some degree, *including inaction and non-comment*. Where the boundary is for the degree on what constitutes a political action and what doesn't varies between people. On Sun, 2020-06-14 at 16:44 -0400, Eric S.

Re: [go-nuts] Re: pure-go implementation of sqlite

2020-06-16 Thread 'Dan Kortschak' via golang-nuts
This is at https://modernc.org/sqlite now, along with the rest of Jan's amazing things, https://gitlab.com/cznic. On Tue, 2020-06-16 at 12:27 -0700, Mandolyte wrote: > SQLite3 support is the stated goal of > https://github.com/elliotchance/c2go > > Also, I believe I tested this one a long time a

[go-nuts] generics and absence of ability to specify correlated types

2020-06-17 Thread 'Dan Kortschak' via golang-nuts
Since this has come up again in [1], I would like to re-raise the issue of being able to correlate float and complex types so that a func(float32) complex64/func(float64) complex128-like function can be written generically. This issue was raised in [2] in the last round of generics discussions with

Re: [go-nuts] generics and absence of ability to specify correlated types

2020-06-18 Thread 'Dan Kortschak' via golang-nuts
With the multitude of answers for use of alternative syntaxes for specifying type parameter lists, is there a chance that this concern could be addressed? thanks Dan On Wed, 2020-06-17 at 11:24 +, 'Dan Kortschak' via golang-nuts wrote: > Since this has come up again in [1], I

[go-nuts] go get with vanity import path and 404: fails

2020-06-20 Thread 'Dan Kortschak' via golang-nuts
Yesterday we replaced the old gonum.org site with a new hugo build. This appears to have broken go get for clients that do not use proxy.golang.org or some other proxy that already has gonum.org/... cached (this includes gddo). ``` $ GOPROXY=direct go get gonum.org/v1/gonum go get gonum.org/v1/gon

Re: [go-nuts] Re: go get with vanity import path and 404: fails

2020-06-20 Thread 'Dan Kortschak' via golang-nuts
Thanks to Tim and Eric Bajumpaa on slack. The issue was due to an error in minification where the quotes around the name attribute value are stripped. Turning off minification is an interim workaround while that is broken. Dan On Sat, 2020-06-20 at 18:10 -0700, Tim Heckman wrote: > Closing the l

Re: [go-nuts] Re: go get with vanity import path and 404: fails

2020-06-21 Thread 'Dan Kortschak' via golang-nuts
As a follow-up to the follow-up, I have filed golang.org/issue/39748; the error is apparently not in minification, but in the go command's handling of html. The workaround remains the same. On Sun, 2020-06-21 at 03:23 +0000, Dan Kortschak wrote: > Thanks to Tim and Eric Bajumpaa

Re: [go-nuts] Bitstring package?

2020-06-29 Thread 'Dan Kortschak' via golang-nuts
Probably math/big.Int will do what you want. Dan On Mon, 2020-06-29 at 18:58 -0700, hardconnect@gmail.com wrote: > I'm looking for a package that implements arbitrary length bit > strings and > supports set all, clear all, set and reading back of arbitrary bits > and setting and clearing the

[go-nuts] retaining mapiterkey return values in *reflect.MapIter

2020-06-30 Thread 'Dan Kortschak' via golang-nuts
Is there a reason not to retain the returned value from `mapiterkey` on line 1243 of reflect/value.go[1] for use on line 1249[2]. ``` // Key returns the key of the iterator's current map entry. func (it *MapIter) Key() Value { if it.it == nil { panic("MapIter.Key called bef

Re: [go-nuts] retaining mapiterkey return values in *reflect.MapIter

2020-06-30 Thread 'Dan Kortschak' via golang-nuts
x27;m actually leaning towards the similarity being a benefit and one that would be broken by retaining the value. Dan On Tue, 2020-06-30 at 19:24 -0700, Ian Lance Taylor wrote: > On Tue, Jun 30, 2020 at 6:39 PM 'Dan Kortschak' via golang-nuts > wrote: > > > > Is there a

Re: [go-nuts] Generics and parentheses

2020-07-15 Thread 'Dan Kortschak' via golang-nuts
On Tue, 2020-07-14 at 23:05 -0700, Bakul Shah wrote: > I don't much like square brackets or angle brackets or guillemets. > But here is a different way > of reducing the need for parentheses at least for the common case: > > A proposal for fewer irritating parentheses! > > One thing to note is

Re: [go-nuts] Generics and parentheses

2020-07-15 Thread 'Dan Kortschak' via golang-nuts
On Tue, 2020-07-14 at 23:53 -0700, Randall O'Reilly wrote: > So, essentially, this puts the onus back on the parser programmers to > definitively *rule out* the use of < > -- is it really that difficult > / costly to do a bit of look-ahead and disambiguate the different use > cases? The absence of

Re: [go-nuts] Generics and parentheses

2020-07-15 Thread &#x27;Dan Kortschak' via golang-nuts
On Wed, 2020-07-15 at 14:36 -0700, Randall O'Reilly wrote: > And the use of [ ] in map is more semantically associated with its > conventional use as an element accessor in arrays / slices, not with > some more general kind of type parameter. The [] syntax can be viewed as an indexing operation pe

Re: [go-nuts] Generics and parentheses

2020-07-15 Thread &#x27;Dan Kortschak' via golang-nuts
On Wed, 2020-07-15 at 17:10 -0500, Seebs wrote: > That said, if people don't like square brackets, I'm totally prepared > to make worse suggestions until they give up and say square brackets > aren't that bad. > Let's bring back the special five keywords! func despiteallobjections F insofaras ty

Re: [go-nuts] Generics and parentheses

2020-07-15 Thread &#x27;Dan Kortschak' via golang-nuts
On Wed, 2020-07-15 at 15:27 -0700, Bakul Shah wrote: > The second issue is the usage for generic functions. Contrast > > (float64, int)PowN(1.2, 3) > with > PowN[float64, int](1.2, 3) > or currently > PowN(float64, int)(1.2, 3) > > I find the alternate syntax easier because conc

Re: [go-nuts] Generics and parentheses

2020-07-15 Thread &#x27;Dan Kortschak' via golang-nuts
On Wed, 2020-07-15 at 18:09 -0700, lotus.developer.mas...@gmail.com wrote: > Personally think this way is easier to read. In this way, I wrote a > few examples, which may be different from the creator Please post in unstyled plain text. It is almost impossible to read the code examples you have th

Re: [go-nuts] Re: Generics and parentheses

2020-07-16 Thread &#x27;Dan Kortschak' via golang-nuts
On Thu, 2020-07-16 at 13:44 -0700, jpap wrote: > Notwithstanding a concise unambiguous alternative, I would rather > type parameters "stick out" so they are easily identified when > visually scanning through code. func ᕙ(⇀ X ↼‶)ᕗ GenericFunction(x X) ... -- You received this message because you

Re: [go-nuts] Re: Generics and parentheses

2020-07-17 Thread &#x27;Dan Kortschak' via golang-nuts
On Fri, 2020-07-17 at 15:56 -0700, Jay Kay wrote: > How about a "-generics" compile flag that lets you select one pair > from a character set of [ ( { < « . This hits two of the things that Go doesn't do: 1. proliferation of compiler option flags 2. enabling dialect spliting -- You recei

Re: [go-nuts] A question about copying

2020-07-25 Thread &#x27;Dan Kortschak' via golang-nuts
On Sat, 2020-07-25 at 01:09 -0700, chri...@surlykke.dk wrote: > &(*f1) > > would, first, create a copy of *f1, and then a pointer to that copy, > but evidently f2 becomes a pointer to the same struct as f1. Is this > something I should have deduced from the language spec? &(*p) says "give me the

Re: [go-nuts] A few thoughts on type parameters

2020-08-03 Thread &#x27;Dan Kortschak' via golang-nuts
On Mon, 2020-08-03 at 10:45 -0700, Ian Lance Taylor wrote: > Another possibility is constraints.Any, although that is no shorter > than interface{}. I'm not sure _ is best; currently _ fairly > consistently means "ignore this value," but in this usage it would > mean something different. Another

[go-nuts] gophers analysing genomes

2020-08-06 Thread &#x27;Dan Kortschak' via golang-nuts
The genome of the New Zealand 'lizard', the tuatara[1], has just been sequenced and published in Nature[2,3]. The analysis of the genome included an examination of the repetitive sequences within the genome. The engine for finding novel repeats for this analysis is written in Go. Gophers analyse

Re: [go-nuts] gophers analysing genomes

2020-08-06 Thread &#x27;Dan Kortschak' via golang-nuts
On Thu, 2020-08-06 at 07:41 +, Sebastien Binet wrote: > ‐‐‐ Original Message ‐‐‐ > On Thursday, August 6, 2020 9:16 AM, 'Dan Kortschak' via golang-nuts > wrote: > > > The genome of the New Zealand 'lizard', the tuatara[1], has just > > be

Re: [go-nuts] How to print arrays with commas and brackets

2020-08-07 Thread &#x27;Dan Kortschak' via golang-nuts
On Wed, 2019-10-09 at 06:02 -0700, Nalin Pushpakumara wrote: > Hi, > I tried to print array with brackets and commas in golang. I want to > get > array like this. > ["record1", "record2". "record3"] > > Does anyone know how to do it? > > Thank you > Not the most efficient, but simple and clear

[go-nuts] obtaining the original type from a named alias type with go/types?

2020-08-15 Thread &#x27;Dan Kortschak' via golang-nuts
I would like to be able to obtain the original type for an alias given a source input. I can see in "go/types" that it's possible to know whether a named type is an alias by `typ.Obj().IsAlias()`, but I cannot see how to obtain the actual original type unless it is an alias for a basic type. Can s

Re: [go-nuts] obtaining the original type from a named alias type with go/types?

2020-08-21 Thread &#x27;Dan Kortschak' via golang-nuts
On Sat, 2020-08-15 at 21:44 -0700, Ian Lance Taylor wrote: > On Sat, Aug 15, 2020 at 3:45 PM 'Dan Kortschak' via golang-nuts > wrote: > > > > I would like to be able to obtain the original type for an alias > > given > > a source input. I can see

Re: [go-nuts] obtaining the original type from a named alias type with go/types?

2020-08-21 Thread &#x27;Dan Kortschak' via golang-nuts
On Sat, 2020-08-22 at 06:00 +0100, Paul Jolly wrote: > I think you were unlucky with your choice of type to experiment with. > My understanding is that byte is special cased, despite being an > alias: > > https://github.com/golang/go/blob/13e41bcde8c788224f4896503b56d42614e0bf97/src/go/types/univ

Re: [go-nuts] obtaining the original type from a named alias type with go/types?

2020-08-21 Thread &#x27;Dan Kortschak' via golang-nuts
On Fri, 2020-08-21 at 21:51 -0700, Ian Lance Taylor wrote: > > > Thanks, Ian. > > > > No that doesn't work. For example with type byte, you get back the > > byte > > name. > > > > https://play.golang.org/p/PPjHBotsIsw > > The underlying type of byte is indeed byte. What are you hoping for? >

Re: [go-nuts] [ANN] CGo-free sqlite database/sql driver 1.4.0 for linux/amd64 released

2020-08-26 Thread &#x27;Dan Kortschak' via golang-nuts
On Wed, 2020-08-26 at 23:50 +0200, Jan Mercl wrote: > From the change log ( > https://godoc.org/modernc.org/sqlite#hdr-Changelog) > > 2020-08-26 v1.4.0: > > First stable release for linux/amd64. The database/sql driver and its > tests are CGo free. Tests of the translated sqlite3.c library still

[go-nuts] cgo godefs questions

2020-09-01 Thread &#x27;Dan Kortschak' via golang-nuts
I am working on some C/Go interop code that includes this horror on the C side (TYPE_BITS is 5 and NAMED_BITS is 16): ``` struct sxpinfo_struct { SEXPTYPE type : TYPE_BITS; /* ==> (FUNSXP == 99) %% 2^5 == 3 == CLOSXP * -> warning:

Re: [go-nuts] cgo godefs questions

2020-09-01 Thread &#x27;Dan Kortschak' via golang-nuts
On Tue, 2020-09-01 at 17:03 -0700, Ian Lance Taylor wrote: > > This is a bug. Sent https://golang.org/cl/252378. > > I think that currently cgo -godefs ignores #cgo lines. This was > recently reported at https://golang.org/issue/41072. > > Ian Thanks, Ian for both of those. Dan -- You

Re: [go-nuts] linux/arm struct alignment seems wrong

2020-09-09 Thread &#x27;Dan Kortschak' via golang-nuts
On Wed, 2020-09-09 at 12:19 +0200, Jan Mercl wrote: > Observation: > > pi@raspberrypi:~/src/tmp.tmp $ go version > go version go1.15.1 linux/arm > pi@raspberrypi:~/src/tmp.tmp $ cat main.go > package main > > /* > > struct s { > long long i; > } x; > > size_t align() { > return

Re: [go-nuts] linux/arm struct alignment seems wrong

2020-09-09 Thread &#x27;Dan Kortschak' via golang-nuts
On Wed, 2020-09-09 at 12:50 +0200, Jan Mercl wrote: > On Wed, Sep 9, 2020 at 12:41 PM Dan Kortschak > wrote: > > > I get the following > > > > ``` > > C alignof struct s: 8 > > Go alignof struct s: 8 > > Go alignofS: 8 > > ~/czn

Re: [go-nuts] linux/arm struct alignment seems wrong

2020-09-09 Thread &#x27;Dan Kortschak' via golang-nuts
On Wed, 2020-09-09 at 13:21 +0200, Jan Mercl wrote: > > > On Wed, Sep 9, 2020 at 1:09 PM 'Dan Kortschak' via golang-nuts < > golang-nuts@googlegroups.com> wrote: > > > What does cgo -godefs give you? On my amd64 and arm64 I get this: > > > &g

Re: [go-nuts] Re: method resolution order

2020-09-16 Thread &#x27;Dan Kortschak' via golang-nuts
Yes, it's sort of like asking what the best way to translate "This sentence is not Spanish." into Spanish; you can do it, but it doesn't make a lot of sense. On Wed, 2020-09-16 at 02:13 -0700, Volker Dobler wrote: > On Wednesday, 16 September 2020 at 10:51:27 UTC+2 > stephan...@gmail.com wrote: >

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

2021-06-30 Thread &#x27;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 wi

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

2021-07-27 Thread &#x27;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

[go-nuts] doc comment for io.Closer

2021-07-29 Thread &#x27;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 Go

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

2021-07-29 Thread &#x27;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 multipl

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

2021-08-10 Thread &#x27;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 whet

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

2021-08-10 Thread &#x27;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 capt

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

2021-08-15 Thread &#x27;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 an

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

2021-08-25 Thread &#x27;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 exam

[go-nuts] no plan9obj.ErrNoSymbols

2021-08-26 Thread &#x27;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] Using a local copy of an external package?

2021-08-26 Thread &#x27;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 t

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

2021-09-04 Thread &#x27;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 d

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

2021-09-04 Thread &#x27;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] slices grow at 25% after 1024 but why 1024?

2021-09-05 Thread &#x27;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 le

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

2021-09-05 Thread &#x27;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 that

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

2021-09-05 Thread &#x27;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] how atomic instruction work?

2021-09-21 Thread &#x27;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] Parse JSON case-sensitively

2021-09-24 Thread &#x27;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 realis

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

2021-09-24 Thread &#x27;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 > > &g

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

2021-09-24 Thread &#x27;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 https://play.golang.org/p/SQyE3R-

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

2021-09-24 Thread &#x27;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 ne

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

2021-09-24 Thread &#x27;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 ne

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

2021-10-08 Thread &#x27;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): %!d(BADINDEX

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

2021-10-08 Thread &#x27;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 [1]https

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

2021-10-24 Thread &#x27;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 initi

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

2021-10-24 Thread &#x27;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 i

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

2021-11-05 Thread &#x27;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 2000

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

2021-11-15 Thread &#x27;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 = int(C.VeProtect(C.

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

2021-12-05 Thread &#x27;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`) > } > https://cs.opensou

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

2021-12-09 Thread &#x27;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 why

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

2022-01-04 Thread &#x27;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 c

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

2022-01-12 Thread &#x27;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 versi

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

2022-01-12 Thread &#x27;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 ri

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

2022-01-20 Thread &#x27;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 Pipeline[T

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

2022-01-30 Thread &#x27;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] Why Go allow function with unused arguments?

2022-01-30 Thread &#x27;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 } > Probab

Re: [go-nuts] Is Go good choice for porting graph based app?

2022-02-03 Thread &#x27;Dan Kortschak' via golang-nuts
On Thu, 2022-02-03 at 14:26 -0800, Kamil Ziemian wrote: > Hello, > > I was handed proof-of-concept app written in Python. It seems > underdeveloped, buggy and running it first time is a pain, because of > dependencies. Basically it need to read some graphs stored in JSON > files and manipulated the

Re: [go-nuts] Re: DataRace with slice, should i fix it or ignore it?

2022-02-10 Thread &#x27;Dan Kortschak' via golang-nuts
On Thu, 2022-02-10 at 09:15 -0800, jake...@gmail.com wrote: > > On Wednesday, February 9, 2022 at 9:14:52 AM UTC-5 peterGo wrote: > > Pelen Li, > > > > Always fix your data races. You should consider the results of data > > races as undefined. > > > > Dmitry Vyukov, who implemented the Go race dete

Re: [go-nuts] Improving on unit test styles

2022-02-28 Thread &#x27;Dan Kortschak' via golang-nuts
On Fri, 2022-02-25 at 09:26 -0800, 'Markus Zimmermann' via golang-nuts wrote: > Would appreciate your feedback on the style and extension. Would be > also interesting to hear other approaches and conventions that could > help others to write better tests. I'm struggling to understand how you captu

Re: [go-nuts] Improving on unit test styles

2022-03-04 Thread &#x27;Dan Kortschak' via golang-nuts
On Thu, 2022-03-03 at 05:50 -0800, twp...@gmail.com wrote: > For debugging an individual test case, just skip over all but the > failing test case: > > for i, testCase := range testCases { > if i != 5 { // 5 is the index of the failing test, remove if > statement before committing >

Re: [go-nuts] Possible float64 precision problem

2022-03-09 Thread &#x27;Dan Kortschak' via golang-nuts
On Wed, 2022-03-09 at 03:37 -0800, christoph...@gmail.com wrote: > I'm translating a scientific C program into Go that is doing some > 64bit floating point operations. > > In this process I check that the same input yields the same output. > Unfortunately they don't yield the same result, though th

Re: [go-nuts] Example of printing in go.dev

2022-03-09 Thread &#x27;Dan Kortschak' via golang-nuts
On Wed, 2022-03-09 at 19:16 -0800, Nikhilesh Susarla wrote: > In https://go.dev/doc/effective_go#printing > I saw an example for printing our custom string output for the type. > The code below is from docs. > func (t *T) String() string { > return fmt.Sprintf("%d/%g/%q", t.a, t.b, t.c) > } > f

Re: [go-nuts] Pointer to a pointer

2022-03-09 Thread &#x27;Dan Kortschak' via golang-nuts
On Wed, 2022-03-09 at 18:58 -0800, shan...@gmail.com wrote: > This morning someone asked about dereferincing a pointer to a pointer > to a pointer > > At first nobody had ever thought about, let alone knew the answer, > but some example code was shown, and sure enough ***val is possible > ``` > pac

<    1   2   3   4   5   6   7   >