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

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

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

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

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

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

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

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

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] 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] 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] 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] 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 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] 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] 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] 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] 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] 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] 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] 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] 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] Pointer to a pointer

2022-03-09 Thread '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 > ``` >

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

2022-03-09 Thread '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) > } >

Re: [go-nuts] Possible float64 precision problem

2022-03-09 Thread '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

Re: [go-nuts] Constrain a type to be either a slice or a map

2022-03-18 Thread 'Dan Kortschak' via golang-nuts
On Thu, 2022-03-17 at 18:47 -0700, RussellLuo wrote: > Is there any way to write a constraint, say, SliceOrMap, to support > either a slice or a map? > > With the help of SliceOrMap, then I can write a more generic version > `LenBetween` like this: > > ```go > func MapLenBetween[T SliceOrMap](s T,

Re: [go-nuts] evaluation of range expression in for-range loop

2022-03-18 Thread 'Dan Kortschak' via golang-nuts
On Fri, 2022-03-18 at 04:43 -0700, Jochen Voss wrote: > Dear all, > > The spec at https://go.dev/ref/spec#For_range says > > "The range expression x is evaluated once before beginning the loop, > with one exception: if at most one iteration variable is present > and len(x) is constant, the range

[go-nuts] workspaces tutorial query

2022-03-12 Thread 'Dan Kortschak' via golang-nuts
I was just taking a look at the workspaces tutorial and saw that while the doc says that adding the local example module will result in go 1.18 use ( ./hello ./example ) what actually results is go 1.18 use ( ./hello example ) The behaviour is

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

2022-02-28 Thread '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

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

2022-03-04 Thread '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] Is Go good choice for porting graph based app?

2022-02-03 Thread '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

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] 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] Re: DataRace with slice, should i fix it or ignore it?

2022-02-10 Thread '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

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] Tool to check binaries for vulnerabilities

2022-04-14 Thread 'Dan Kortschak' via golang-nuts
On Thu, 2022-04-14 at 03:05 -0700, Michel Casabianca wrote: > Any comment and contribution welcome. Can I suggest that you use golang.org/x/sys/execabs rather than os/exec in ExecCommand? -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To

Re: [go-nuts] Go 1.18: reflect implicit type conversion

2022-04-16 Thread 'Dan Kortschak' via golang-nuts
On Fri, 2022-04-15 at 18:33 -0700, Dave Keck wrote: > Hi all, > > In this code, the SetMapIndex line panics in Go <1.18, but it no > longer panics in Go 1.18: > > type CustomString string > m := reflect.ValueOf(map[CustomString]int{}) > m.SetMapIndex(reflect.ValueOf("key"),

[go-nuts] semantics of panic stack traces

2023-09-17 Thread 'Dan Kortschak' via golang-nuts
I'm trying to get my head around a panic stack trace from a user report[1]. The parameter value make very little sense to me based on what they should be from following the program logic. For example the {0x0?, 0x0, 0x1?} (a slice header len=0) in

Re: [go-nuts] how to write methods for a generic Matrix[float64 constrained by Addable]?

2023-09-09 Thread 'Dan Kortschak' via golang-nuts
On Sat, 2023-09-09 at 15:39 -0700, Jason E. Aten wrote: > New to generics... how can I write a method for a Matrix[float64] > that uses a math function that expects a float64?   I get: > > ./slurp1.go:936:18: cannot use m.At(i, j) (value of type float64 > constrained by Addable) as float64 value

Re: [go-nuts] Re: Clace: Secure web application development platform using Starlark

2023-10-30 Thread 'Dan Kortschak' via golang-nuts
On Mon, 2023-10-30 at 18:43 -0700, Jason E. Aten wrote: > I'm surprised by that claim. I seriously doubt, from reading the > licenses, that you can legally use the Apache2 license, since > it removes the MPL requirements; which the MPL forbids you from > doing.   > The Mozilla FAQ

Re: [go-nuts] Re: Clace: Secure web application development platform using Starlark

2023-10-31 Thread 'Dan Kortschak' via golang-nuts
On Mon, 2023-10-30 at 23:29 -0700, TheDiveO wrote: > Unfortunatelly, "okay" hasn't been tested in court yet and especially > with HashiCorp breaking bad you surely have the deep pockets to see > this through? This is not really my problem, I was just pointing out that the authors of the license

Re: [go-nuts] Re: Clace: Secure web application development platform using Starlark

2023-10-31 Thread 'Dan Kortschak' via golang-nuts
On Tue, 2023-10-31 at 02:50 -0700, Jason E. Aten wrote: > > > On Tuesday, October 31, 2023 at 3:12:13 AM UTC Dan Kortschak wrote: > > The Mozilla FAQ https://www.mozilla.org/en-US/MPL/2.0/FAQ/ appears > > to > > think it's OK. > > > > > Q13: May I combi

Re: [go-nuts] Can we not invoke methods on types referring to generics?

2023-10-19 Thread 'Dan Kortschak' via golang-nuts
On Fri, 2023-10-20 at 11:56 +0700, Nurahmadie Nurahmadie wrote: > why is there no, type coercion, as you said, that allow the new type > to be acknowledged as its underlying type? which will not be a > question if otherwise Go has mechanism to allow methods to be > attached to foreign types.

Re: [go-nuts] Can Generics match implementers of an interface?

2023-10-21 Thread 'Dan Kortschak' via golang-nuts
On Sat, 2023-10-21 at 11:58 -0700, Mike Schinkel wrote: > Recently I was trying to write a func using generics where I wanted > to use a slice of an interface that would contain implementers of > that interface and then pass those types to a generic function, but I > ran into this error: > > type

Re: [go-nuts] Dynamic template data from yaml

2023-10-14 Thread 'Dan Kortschak' via golang-nuts
On Sat, 2023-10-14 at 13:15 -0700, Tong Sun wrote: > Hmm... somehow I had the impression that only the exported fields can > be used in template as variables. > > Is that a wrong impression or things have changed? You are indexing into a map so so the notion of fields is not relevant. -- You

Re: [go-nuts] Dynamic template data from yaml

2023-10-14 Thread 'Dan Kortschak' via golang-nuts
On Sat, 2023-10-14 at 09:33 -0700, Tong Sun wrote: > Please take a look at  > https://go.dev/play/p/dTDR50dtHB0 > > I want to > > - define my template data dynamically from yaml > - and export the yaml data if they are unexported > > I.e., for the following code: > > t :=

Re: [go-nuts] weird "index out of range" in strconv.formatBits

2023-08-16 Thread 'Dan Kortschak' via golang-nuts
On Wed, 2023-08-16 at 20:31 -0700, metronome wrote: > Hi, > > We ran into a weird out of range issue of strconv.formatBits, hope > someone can shed a light on what could be the root cause, any comment > is highly appreciated. > > problem description: >       random out of range at code, most of

Re: [go-nuts] weird "index out of range" in strconv.formatBits

2023-08-17 Thread 'Dan Kortschak' via golang-nuts
On Wed, 2023-08-16 at 23:43 -0700, metronome wrote: > Thanks for commenting, a few supplements. > > # 1. Version of Go? > We observed the issue with both go1.20.5 and go1.18.10 on linux/amd64 > (centos) > > # 2. Context? > All panics we observed so far are from either  >                  

Re: [go-nuts] keyword= support for function calls

2023-08-17 Thread 'Dan Kortschak' via golang-nuts
On Thu, 2023-08-17 at 11:34 +0200, Peter Herth wrote: > I think the omission of keyword parameters in Go is a weakness. In > many cases, keyword parameters are a simple way of creating APIs, > which depend on a lot of possible parameters, of which most are not > necessarily specified. Their

Re: [go-nuts] weird "index out of range" in strconv.formatBits

2023-08-18 Thread 'Dan Kortschak' via golang-nuts
On Thu, 2023-08-17 at 23:32 -0700, metronome wrote: > > > Have you built with CGO_ENABLED=0? > Building with CGO_ENABLED=0 succeeded, does that mean the binary's > runtime behavior has nothing to do with CGO, deploying > a CGO_ENABLED=0 binary online is not an option as well, for now (We > are

Re: [go-nuts] Why is foo in my go.sum file?

2023-08-18 Thread 'Dan Kortschak' via golang-nuts
On Fri, 2023-08-18 at 16:49 +1000, Nigel Tao wrote: > The go.sum file in the golang.org/x/image repo has a line that is not > another golang.org.x/* module: > > github.com/yuin/goldmark v1.4.13/go.mod > h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY= > >

Re: [go-nuts] does gonum insist on row-major?

2023-08-26 Thread 'Dan Kortschak' via golang-nuts
On Sat, 2023-08-26 at 13:45 +0100, Jason E. Aten wrote: > ah... there is documentation, it is just buried... > > https://pkg.go.dev/gonum.org/v1/gonum/mat#section-readme > > "All matrices are stored in row-major format and users should > consider this when expressing matrix arithmetic to ensure

Re: [go-nuts] does gonum insist on row-major?

2023-08-26 Thread 'Dan Kortschak' via golang-nuts
On Sat, 2023-08-26 at 07:28 -0700, Brian Candler wrote: > Could you explain the comment "all of Go is cm"? > https://go.dev/play/p/tDJiSTqsiSC > Sorry, that was a typo, should read "all of Go is rm" (what is there is inconsistent with everything else I wrote). -- You received this message

Re: [go-nuts] Possible fuzz testing issue on Windows

2022-04-24 Thread 'Dan Kortschak' via golang-nuts
On Sun, 2022-04-24 at 05:21 -0700, Tiago Katcipis wrote: > Hi, > > I was playing around with Go's fuzz support on a pet project of mine > and as the fuzzer found some offending inputs it created the corpus > entries on the file system. I fixed the issues but then something > interesting happened

Re: [go-nuts] Possible fuzz testing issue on Windows

2022-04-25 Thread 'Dan Kortschak' via golang-nuts
On Mon, 2022-04-25 at 05:39 +, 'Dan Kortschak' via golang-nuts wrote: > > I suspect that this is from GitHub checking out the code on windows > with autocrlf and so converting perfectly sensible \n to \r\n, which > is > then not properly handled by this > https://github.

Re: [go-nuts] How to prevent default sorting of map

2022-05-30 Thread 'Dan Kortschak' via golang-nuts
On Mon, 2022-05-30 at 08:23 -0700, Vejju Deepesh wrote: > I want know the method of preventing sorting by default and maintain > the map in the order of insertion If you want ordered return of elements and O(1) look-up, use a slice and an index map. Insertion becomes and appends and a map

Re: [go-nuts] Is this a compilation optimization bug ?

2022-06-29 Thread 'Dan Kortschak' via golang-nuts
On Tue, 2022-06-28 at 09:40 -0700, Ian Lance Taylor wrote: > Please open an issue.  Thanks. Filed https://go.dev/issue/53600. 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,

Re: [go-nuts] Is this a compilation optimization bug ?

2022-06-28 Thread 'Dan Kortschak' via golang-nuts
On Mon, 2022-06-27 at 23:32 -0700, iori yamada wrote: > Running the code in the link below times out, is this a bug? > Looking at the assembly, it seems that the instructions corresponding > to the if statement have been removed due to optimization. > > https://go.dev/play/p/CZX4mbyrp37 > > The

Re: [go-nuts] unrecognized import path "code.google.com/p/go.crypto/openpgp"

2022-06-09 Thread 'Dan Kortschak' via golang-nuts
On Thu, 2022-06-09 at 14:21 -0700, Peter Sjolin wrote: > I attempted to use "code.google.com/p/go.crypto/openpgp" in my > project and got the following error: > $ go get code.google.com/p/go.crypto/openpgp > go: unrecognized import path "code.google.com/p/go.crypto/openpgp": > parse

Re: [go-nuts] Re: duration^2

2022-07-19 Thread 'Dan Kortschak' via golang-nuts
On Tue, 2022-07-19 at 09:24 -0700, Amnon wrote: > > time.NewTicker( time.Duration(n) * time.Second )  ok : duration > > * duration [s^2] square-seconds ? > > Yes, this bothers the inner Physicist in me too. > But you can only multiply numbers if they are of the same type... With a small

Re: [go-nuts] Methods of reflect pkg use mostly panic instead of return error. Why so?

2022-07-20 Thread 'Dan Kortschak' via golang-nuts
On Wed, 2022-07-20 at 22:51 +0200, 'Axel Wagner' via golang-nuts wrote: > The reason reflect uses panic, is for convenience. It would be > inconvenient having to check an error at every reflect call. The other reason is that a panic in reflect is as close as you can get in runtime to a compile

Re: [go-nuts] go fails to detect a point-time race condition

2022-04-30 Thread 'Dan Kortschak' via golang-nuts
On Fri, 2022-04-29 at 23:18 -0700, Zhaoxun Yan wrote: > And then in that folder you run: > # go build -race > Nothing happens, at least in my go1.15 The race detector needs to run to detect data races; it's not a static analysis tool. So if you execute the binary that you built with `go build

Re: [go-nuts] go fails to detect a point-time race condition

2022-04-30 Thread 'Dan Kortschak' via golang-nuts
On Fri, 2022-04-29 at 23:29 -0700, Zhaoxun Yan wrote: > Hi Dan! > > I did as you told, but go build -race still not functions: > zxun@zxun-virtual:~/src/race2$ go build > zxun@zxun-virtual:~/src/race2$ ls > race2 race.go > zxun@zxun-virtual:~/src/race2$ go build -race race2 >

Re: [go-nuts] go fails to detect a point-time race condition

2022-05-01 Thread 'Dan Kortschak' via golang-nuts
On Sat, 2022-04-30 at 22:49 -0700, Zhaoxun Yan wrote: > I am sure it did not detect race immediately at least in my > project, which has similar global variable race conditions, but in a > more subtle way . > > For example, the checking of one global variable is from an > incoming message from

Re: [go-nuts] how is xml.Decoder.CharsetReader supposed to be held?

2022-05-06 Thread 'Dan Kortschak' via golang-nuts
On Fri, 2022-05-06 at 11:22 +0200, Diego Joss wrote: > Does this work for you? > > https://go.dev/play/p/xLRawVhcRtF > Thanks. No, the documents are in UTF-16, and the procinst will be too. So it looks more like this https://go.dev/play/p/4IcXNI3yd2M. If I pull the proc inst out of the UTF-16,

Re: [go-nuts] how is xml.Decoder.CharsetReader supposed to be held?

2022-05-06 Thread 'Dan Kortschak' via golang-nuts
On Fri, 2022-05-06 at 15:55 -0700, Ian Lance Taylor wrote: > On Fri, May 6, 2022 at 3:07 AM 'Dan Kortschak' via golang-nuts > wrote: > > > > On Fri, 2022-05-06 at 11:22 +0200, Diego Joss wrote: > > > Does this work for you? > > > > > > https://g

Re: [go-nuts] Which is the most efficient way to read STDIN lines 100s of MB long and tens of MB info is passed to it

2022-05-07 Thread 'Dan Kortschak' via golang-nuts
On Sat, 2022-05-07 at 15:18 -0700, Amnon wrote: > The other interesting question is what algorithm we use to find the > pattern in each line. > Generally bytes.Contains uses Rabin-Karp. But as the pattern is the > word "test" which is only 4 bytes long, > a brute force search is used, using SSE

Re: [go-nuts] Which is the most efficient way to read STDIN lines 100s of MB long and tens of MB info is passed to it

2022-05-07 Thread 'Dan Kortschak' via golang-nuts
On Sat, 2022-05-07 at 16:16 -0700, Const V wrote: > The question is will scanner.Scan handle a line of 100s MB? No, at least not by default (https://pkg.go.dev/bufio#Scanner.Buffer). But that that point you want to start questioning why you're doing what you're doing. Your invocation of grep can

[go-nuts] how is xml.Decoder.CharsetReader supposed to be held?

2022-05-05 Thread 'Dan Kortschak' via golang-nuts
I'm in the situation of needing to provide cross-platform xml decoding. So I thought that xml.Decoder.CharsetReader would be the right approach in conjunction with golag.org/x/text/encoding. However, the xml decoder needs to be able to understand the text in order to be able to read the proc inst

Re: [go-nuts] Is Go a security malware risk?

2022-08-25 Thread 'Dan Kortschak' via golang-nuts
On Thu, 2022-08-25 at 01:47 -0700, Holloway Kean Ho wrote: > What exactly you're trying to achieve by taking a very elaborated, > crystal-clear, good-willed security-related article way out of its > context with your thread title here and agitate some of the Go > maintainers here? I don't think

Re: [go-nuts] How to resolve error Cannot use 'struct{ width, height float64 }{2.0, 3.0}' (type struct {...}) as the type struct {...}

2022-08-30 Thread 'Dan Kortschak' via golang-nuts
On Tue, 2022-08-30 at 07:46 -0700, Richard Whatever wrote: > I'm developing a mvc Golang server. > The model file is as follows: >  type Object struct { ... TargetSize struct{ width, height float64 } > `json:"targetSize"` ... } > The controller file is as follows: > func (c *GetObject) Get()

Re: [go-nuts] Is Go a security malware risk?

2022-08-22 Thread 'Dan Kortschak' via golang-nuts
On Mon, 2022-08-22 at 06:15 -0700, 'Gopher-Insane' via golang-nuts wrote: > Hi > > So our security team has raised a concern with Go and malware. The > link that was sent to me > was https://securityboulevard.com/2021/09/behavior-based-detection-ca > n-stop-exotic-malware/.  > I reached out to

Re: [go-nuts] time.Truncate unexpected results in non-hour aligned timezones

2022-08-24 Thread 'Dan Kortschak' via golang-nuts
On Tue, 2022-08-23 at 23:07 -0700, Mine GO BOOM wrote: > Our system recently experienced a bug because of the surprise that > sits (documented) inside of time.Truncate(): > > """ > Truncate operates on the time as an absolute duration since the zero > time; it does not operate on the presentation

Re: [go-nuts] understanding interface conversions

2022-09-22 Thread 'Dan Kortschak' via golang-nuts
On Thu, 2022-09-22 at 20:01 -0500, Robert Engels wrote: > The world figured out long ago that OO and it’s principles are a > better way to go. This is a very strong assertion (pun not intended). I heartily disagree with the claim, particularly when it comes to how OO is implemented by class-based

<    1   2   3   4   5   6   7   >