Re: [go-nuts] Preserving special characters when reading Go POST request body

2024-07-02 Thread 'Dan Kortschak' via golang-nuts
On Mon, 2024-07-01 at 12:03 -0700, Hugh Myrie wrote: > I am trying to preserve special characters (group separators and > field separators) when reading the request body from a POST request. > > When I do a dumpRequest I am able to see the special characters (Hex > Format, for example: \x1c or

Re: [go-nuts] strip / reduce module compile size

2024-06-14 Thread 'Dan Kortschak' via golang-nuts
On Fri, 2024-06-14 at 19:35 -0500, robert engels wrote: > Something doesn’t seem right... You state the total compiled size is > 22MB, but the first 3 entries combined are more than that. It looks like goweight just gets the size of the .a files that are generated during the build and returns the

Re: [go-nuts] var errors stdlib

2024-05-10 Thread 'Dan Kortschak' via golang-nuts
On Fri, 2024-05-10 at 04:24 -0700, Sebastian Bogan wrote: > Hello Everyone, > > I was wondering, what was / is the reason for exposing errors as > public vars - rather than constants? Doesn't that impose some risk? > > For example: > >   fs.ErrNotExist = errors.New("foo") >   _, err =

Re: [go-nuts] Re: couldn't print numbers ordered with goroutine

2024-04-20 Thread 'Dan Kortschak' via golang-nuts
On Sun, 2024-04-21 at 15:06 +1200, Justin Israel wrote: > And really I wasn't even commenting on the nature of the channel. > Only the scheduling of the goroutines. Buffered or not, they would > still be random order right?  Absolutely. Your answer was spot on. The issue is the ordering of the

Re: [go-nuts] Re: couldn't print numbers ordered with goroutine

2024-04-20 Thread 'Dan Kortschak' via golang-nuts
On Sat, 2024-04-20 at 18:55 -0700, Robert Solomon wrote: > channels are not queues, as Justin said They can be; buffered channels are queues. >From https://go.dev/ref/spec#Channel_types > Channels act as first-in-first-out queues. For example, if one > goroutine sends values on a channel and a

Re: [go-nuts] why math.Pow gives different results depending on exp type

2024-04-20 Thread 'Dan Kortschak' via golang-nuts
On Fri, 2024-04-19 at 22:51 -0700, DrGo wrote: > ``` > package main > > import ( > "fmt" > "math" > ) > > func main() { > fmt.Printf("%g\n", 1-(math.Pow(0.6, 1/13)))   //result=0 > fmt.Printf("%g\n", 1-(math.Pow(0.6, 1.0/13))) // > result=0.038532272011602364 > } > ```

Re: [go-nuts] Re: Trying to understand aversion to main package

2024-02-14 Thread 'Dan Kortschak' via golang-nuts
On Wed, 2024-02-14 at 15:31 -0800, Jeremy French wrote: > I really think the testability issue is the biggest one.  Generally, > testing the main package iscumbersome at least.  So it's > reasonable to say, "I'm not going to test the main package, but I > will keep it so simple that it is

Re: [go-nuts] big int panic on text conversion

2024-02-14 Thread 'Dan Kortschak' via golang-nuts
On Wed, 2024-02-14 at 12:24 +0100, Jan Mercl wrote: > On Wed, Feb 14, 2024 at 12:14 PM 'Dan Kortschak' via golang-nuts > wrote: > > > Given that this can happen without a race or unsafe modifications > > it > > might be worth filing a issue for. > > I thi

Re: [go-nuts] Trying to understand aversion to main package

2024-02-14 Thread 'Dan Kortschak' via golang-nuts
On Wed, 2024-02-14 at 03:12 -0800, Jerry Londergaard wrote: > I see quite a few modules out there where they seem to be putting in > as little into the main package as possible. Literally they will > sometimes be a few lines: > ``` > import foobar > func main() { >     os.Exit(foobar.Run()) > } >

Re: [go-nuts] big int panic on text conversion

2024-02-14 Thread 'Dan Kortschak' via golang-nuts
On Wed, 2024-02-14 at 02:07 -0800, Poonai wrote: > Thanks all, > > figured out the issue: > > func main() { >     a := big.NewInt(1) >     b := *a >     c := *a >     c.Sub(, big.NewInt(1)) >     fmt.Println(b.String()) >     fmt.Println(c.String()) >     fmt.Println(a.String()) > } > > >

Re: [go-nuts] big int panic on text conversion

2024-02-13 Thread 'Dan Kortschak' via golang-nuts
On Tue, 2024-02-13 at 21:35 -0800, Poonai wrote: > big int panics during text conversion randomly  > > stack trace: > > panic: runtime error: index out of range [1] with length 1 > > goroutine 2088184 [running]: > math/big.nat.itoa({0xc01db71500, 0x1, 0x199?}, 0x0, 0xa) >        

Re: [go-nuts] Re: need a package to read/write shell history flat file database

2024-02-10 Thread 'Dan Kortschak' via golang-nuts
On Sat, 2024-02-10 at 21:01 -0800, Kurtis Rader wrote: > The only solution I can find that gets close to my requirements is > https://github.com/ergochat/readline, but AFAICT it does not handle > updates to the on-disk history file by concurrently executing > processes. There is also

Re: [go-nuts] Incorrect "missing return" error for an edge case

2024-01-07 Thread 'Dan Kortschak' via golang-nuts
On Mon, 2024-01-08 at 06:21 +0100, 'Axel Wagner' via golang-nuts wrote: > The "missing return" error is defined in the spec, by requiring a > function to end in a terminating statement: > https://go.dev/ref/spec#Terminating_statements > The list is necessarily not complete. So it is necessarily

Re: [go-nuts] Re: How to get net.Conn in rpc function in net/rpc

2023-12-28 Thread 'Dan Kortschak' via golang-nuts
On Thu, 2023-12-28 at 13:14 -0800, 'Christian Stewart' via golang-nuts wrote: > I agree with what Brian said and would like to suggest the following > two way RPC library with multiplexing over a single connection of any > type: > > https://github.com/aperturerobotics/starpc > There is also

Re: [go-nuts] Need help running "go get" on self hosted git server

2023-12-18 Thread 'Dan Kortschak' via golang-nuts
On Sun, 2023-12-17 at 07:06 -0800, Brijesh Wawdhane wrote: > I added a go-import meta tag to my git server's website on the repo > page and it looks like > > https://brijesh.dev/kairos.git;> > > but when I try running "go get brijesh.dev/kairos" I get an error > saying 'go: unrecognized import

Re: [go-nuts] Re: Is "When in doubt, use a pointer receiver" misleading advice?

2023-11-13 Thread 'Dan Kortschak' via golang-nuts
On Mon, 2023-11-13 at 19:38 -0800, Mike Schinkel wrote: > I have been wondering for a while why the advice against mixing > pointer and value receivers, which GoLang so often flags me for > doing. https://dave.cheney.net/2015/11/18/wednesday-pop-quiz-spot-the-race -- You received this message

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

[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] 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] 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] 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] 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-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] 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] [RFC] Yet another proposal for Go2 error handling

2023-07-02 Thread 'Dan Kortschak' via golang-nuts
On Sun, 2023-07-02 at 10:41 -0700, Jeremy French wrote: > Scrolling in code is bad - a necessary evil, obviously, but evil > nonetheless.  Vertical scrolling is bad because it causes what we > were looking at to move and our eyes have to track and/or reacquire > what we were looking at.  It's

Re: [go-nuts] [RFC] Yet another proposal for Go2 error handling

2023-07-01 Thread 'Dan Kortschak' via golang-nuts
On Sat, 2023-07-01 at 22:34 -0700, Mike Schinkel wrote: > > What is the difference to if err != nil { goto } ? > > Thanks you for asking. > > If you run go fmt  on a file that contains the formatting you ask > about the line will be expanded to the 3 lines, which brings us back > to status quo:

Re: [go-nuts] fmt.Printf Go-syntax formated representation of the value

2023-04-28 Thread 'Dan Kortschak' via golang-nuts
On Thu, 2023-04-27 at 23:02 -0700, Jérôme LAFORGE wrote: > Hello, > In my unit tests when expected is not the actual result, I like > display actual value with Go-syntax. For example: > if got != expected { > t.Errorf(" %#v", got) // []string{"blah','blah"} > } > > But it want to know if

Re: [go-nuts] Short Variable Declarations Are Oversold

2023-04-22 Thread 'Dan Kortschak' via golang-nuts
On Sat, 2023-04-22 at 15:31 -0700, jlfo...@berkeley.edu wrote: > What type should I use to declare “file” in the parameter list for > myfunc()? As a new Go programmer I have to admit that I haven’t > memorized all the types used in the Go standard library. So, I have > to break off working on

Re: [go-nuts] Is there a gofmt flag to avoid reformatting comments?

2023-04-19 Thread 'Dan Kortschak' via golang-nuts
On Wed, 2023-04-19 at 14:30 -0700, Ian Lance Taylor wrote: > > If you give us more details perhaps there is some common ground > available.  In particular, a sequence of lines where each line is > indented will be treated as a code block, and not reformatted. Related, I'd like to reiterate the

Re: [go-nuts] Avoid forcing my module users' to carry dependencies from code that live under the same repo just as examples/ debugging purposes.

2023-04-14 Thread 'Dan Kortschak' via golang-nuts
On Fri, 2023-04-14 at 14:01 +0800, Jim Idle wrote: > You might start with this repo: > > https://github.com/golang-standards/project-layout > > This is not an 'official' standard, though it does encapsulate the > things that are standard go such as the internal directory.  > > Personally I

Re: [go-nuts] Interesting "select" examples

2023-04-06 Thread 'Dan Kortschak' via golang-nuts
On Mon, 2023-04-03 at 14:59 -0700, Skip Tavakkolian wrote: > Nice pause/resume. I'll need to remember this. > > On Mon, Apr 3, 2023 at 3:14 AM Rob Pike wrote: > > > > Here's an excerpt from a piece of concurrent code I like, an > > unpublished interactive game of life. The select near the bottom

Re: [go-nuts] How to generalize parameters for a function

2023-03-15 Thread 'Dan Kortschak' via golang-nuts
On Wed, 2023-03-15 at 12:55 -0400, Frank Juedes wrote: > > > Hi Dan, > Thank you very much for your answer, so that's the data structure > behind maps, very interesting. > I had actually thought about using unsafe pointers and then type- > casting, but that is how i would have done it in the

Re: [go-nuts] How to generalize parameters for a function

2023-03-15 Thread 'Dan Kortschak' via golang-nuts
On Tue, 2023-03-14 at 19:56 -0700, Kurtis Rader wrote: > Maps are a special-case. You can't pass them "by value" in the sense > you mean because a "map" value is a very tiny structure that contains > a pointer to the actual map. The passed value is a pointer to the header, otherwise changes to

Re: [go-nuts] overriding image.Decode image type detection

2023-03-05 Thread 'Dan Kortschak' via golang-nuts
On Mon, 2023-03-06 at 14:38 +1100, Nigel Tao wrote: > On Sun, Feb 26, 2023 at 12:43 PM 'Dan Kortschak' via golang-nuts > wrote: > > The alternative is to > > replicate the image.Decode functionality, including registration > > which > > seems ugly. > > I

[go-nuts] overriding image.Decode image type detection

2023-02-25 Thread 'Dan Kortschak' via golang-nuts
I'm implementing a image renderer on an external device and want to include GIF animation support. So far this is working fine, but I've found a difficulty that comes from for image.Decode's file type detection is registered. What I have is shim type that wraps *gif.GIF but also implements

Re: [go-nuts] %v display of nil map

2023-01-25 Thread 'Dan Kortschak' via golang-nuts
On Wed, 2023-01-25 at 07:21 -0800, Andrew Athan wrote: > I'm sure I'm not the first to say this, but here's my +1: > > It seems wrong to me that golang displays nil-valued reference types > as an empty instance of the type with no indication that the > reference is nil. > > E.g. > ``` > var m

Re: [go-nuts] Which tool provide's the Go playground's import handling...

2023-01-06 Thread 'Dan Kortschak' via golang-nuts
On Fri, 2023-01-06 at 00:13 -0800, 'Mark' via golang-nuts wrote: > If I visit the Go playground and change the body of `main()` to, say, > `fmt.Println("hello", math.Abs(-5))` and then click Run, the `import > "fmt"` line is _automatically_ corrected to be `import > (\n\t"fmt"\n\t"math"\n)`. I'd

Re: [go-nuts] More details regarding changes to time.Time JSON marshalling/unmarshalling in 1.20?

2023-01-04 Thread 'Dan Kortschak' via golang-nuts
On Tue, 2023-01-03 at 20:50 -0800, 'Ben Brcan' via golang-nuts wrote: > Hi, I noticed this in the draft release notes for 1.20: > > The Time.MarshalJSON and Time.UnmarshalJSON methods are now more > strict about adherence to RFC 3339. > > Can we get some further details about this? Are there

Re: [go-nuts] MATLAB filtfilt --> GOLANG

2023-01-01 Thread 'Dan Kortschak' via golang-nuts
On Sun, 2023-01-01 at 12:24 -0800, 이석태 wrote: > Hello, Golang Team, > > I want to convert MATLAB ' filtfilt ' command to Golang. > Actually, MATLAB 'filtfilt' command was 'filter' command as a  > one dimensional signal filter. > > I am using 6 * 1 matrix coefficienct for 'filter' command. > > Is

Re: [go-nuts] How to expoert DWARF and symbol table in a in separate file when build?

2022-12-28 Thread 'Dan Kortschak' via golang-nuts
On Wed, 2022-12-28 at 18:14 -0800, 庞子元 wrote: > Hi All, > > For security reasons, our go cannot be compiled with information like > DWARF and symbol tables.  > > Is there a way to put this information in a separate file so that we > can link to it when we need it? > > Any tips are greatly

Re: [go-nuts] Linting

2022-12-10 Thread 'Dan Kortschak' via golang-nuts
On Sat, 2022-12-10 at 14:44 +0100, Marcello H wrote: > golangci_lint ... > > Op za 10 dec. 2022 om 13:17 schreef Brian Candler > : > > The question remains, which linter(s) are you using? golangci_lint is not really an answer to this question since it's just a collection of linters, many of which

Re: [go-nuts] Re: Looking Backend Dev Learning Resources

2022-12-05 Thread 'Dan Kortschak' via golang-nuts
On Mon, 2022-12-05 at 14:54 -0600, Robert Engels wrote: > Can you elaborate on that reference? At first review, it means you > are putting in lots of effort making lots of progress (anti red > queen) but that would mean the progress made did not invalidate any > of effective Go (which seems not

Re: [go-nuts] Re: Looking Backend Dev Learning Resources

2022-12-05 Thread 'Dan Kortschak' via golang-nuts
On Mon, 2022-12-05 at 09:27 -0800, Tsvetomir Lazarov wrote: > How relevant is Effective Go actually, given the January 2022 update > that this document has not been updated significantly since 2009? Still relevant. This is one of the virtues of having a language that is not built on the Red Queen

Re: [go-nuts] Re: go install of forked repo

2022-12-05 Thread 'Dan Kortschak' via golang-nuts
On Sun, 2022-12-04 at 23:47 -0800, 'Christian Stewart' via golang-nuts wrote: > I definitely fork things and use "replace" quite frequently. It *can* be used, but it is not the solution in the general case as Volker said. A replace in a library's go.mod file has no effect on consumers of that

Re: [go-nuts] cgo C.uint64_t compatiblity on multiple platforms?

2022-12-03 Thread 'Dan Kortschak' via golang-nuts
On Sat, 2022-12-03 at 10:51 -0800, David Stainton wrote: > Greetings, > > I think my question is something like: "how to make my usage of > C.uint64_t work on all platforms?" or "Is there something obviously > wrong with my cgo bindings that is causing this not to build on all > platforms?" > > I

Re: [go-nuts] How to fix an awful marshal reflection hack

2022-12-01 Thread 'Dan Kortschak' via golang-nuts
On Thu, 2022-12-01 at 00:33 -0800, 'Mark' via golang-nuts wrote: > Thanks. I've now tried that as follows: > >         fmt.Printf("@@: %T %v\n", field, field) >         kind = field.Type().Elem().Kind() >         fmt.Printf("##: %T %v\n", field, field) > > In every case the output for kind

Re: [go-nuts] clarifying Go FAQ: Is Go an object-oriented language?

2022-11-22 Thread 'Dan Kortschak' via golang-nuts
On Tue, 2022-11-22 at 10:16 -0800, Ian Lance Taylor wrote: > On Tue, Nov 22, 2022 at 10:11 AM Robert Engels > wrote: > > > > I do not know why the mailing list is set up as the sender is the > > user. Is should always have the sender be the list email and the > > name be the user, or the sender

Re: [go-nuts] where is GOROOT set?

2022-11-17 Thread 'Dan Kortschak' via golang-nuts
On Thu, 2022-11-17 at 21:20 -0800, pat2...@gmail.com wrote: > pfarrell@Alien15:~/whome/sandbox/gows/src/github.com/pfarrell51/cmd$ > go test treesort_test.go This is not how go test should be invoked. You just need to do go test in the directory that you package lives in. See

Re: [go-nuts] BUGFIX-66: Algorithmic Puzzles in Go

2022-11-14 Thread 'Dan Kortschak' via golang-nuts
On Sun, 2022-11-13 at 14:43 -0800, Lawrence Ryan wrote: > So you're suggesting that a user could write code containing a race, > have that code produce, say, a slice with the wrong length (by > interleaving the pointer and length/capacity writes), and then use > that "mixed" slice to compromise

Re: [go-nuts] Re: Unicode variable name error

2022-11-08 Thread 'Dan Kortschak' via golang-nuts
On Tue, 2022-11-08 at 09:17 -0800, TheDiveO wrote: > I've always wondered how to deal with exported versus unexported > identifiers in scripts like Chinese? There is an issue for this https://go.dev/issue/22188 which discusses the approaches that are currently used with a view to making it

Re: [go-nuts] Parsing comments that don't start with a space

2022-11-06 Thread 'Dan Kortschak' via golang-nuts
On Sun, 2022-11-06 at 11:55 -0800, 'Christian Stewart' via golang-nuts wrote: >  - Why does the comment not appear unless I put a space before? (in > ast CommentMap) This is explained here https://pkg.go.dev/go/ast#CommentGroup.Text > Comment directives like "//line" and "//go:noinline" are also

Re: [go-nuts] Re: go:embed question

2022-10-14 Thread 'Dan Kortschak' via golang-nuts
On Fri, 2022-10-14 at 00:17 -0700, esimov wrote: > . Now, that's not the case when you are running a package using the > following command: "go run github.com/user/package@latest" for > example Can you give an example of a real package where this doesn't work? -- You received this message

Re: [go-nuts] Go routine context

2022-10-02 Thread 'Dan Kortschak' via golang-nuts
On Mon, 2022-10-03 at 00:46 +0200, Sven Anderson wrote: > As it happens, I wrote a small package, that does that „almost“ > legally:  > https://pkg.go.dev/github.com/ansiwen/gctx There is also github.com/kortschak/goroutine for getting goroutine IDs, which can be used as the primitive for

Re: [go-nuts] Go routine context

2022-10-02 Thread 'Dan Kortschak' via golang-nuts
On Sun, 2022-10-02 at 06:15 -0500, Robert Engels wrote: > Again, I would like a link to the source of statement to evaluate it > in context.  https://manningbooks.medium.com/interview-with-brian-goetz-7d6c47d05d63 -- You received this message because you are subscribed to the Google Groups

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

Re: [go-nuts] cannot convert fs.FS zip file to io.ReadSeeker (missing Seek)

2022-09-21 Thread 'Dan Kortschak' via golang-nuts
On Wed, 2022-09-21 at 19:30 -0500, robert engels wrote: > Others have suggested passing a ByteBuffer - I don’t think that will > work because you will be missing other methods that are probably > needed (FileInfo to get the name, etc) The function that was pointed to takes an ~io.ReadSeeker

Re: [go-nuts] cannot convert fs.FS zip file to io.ReadSeeker (missing Seek)

2022-09-21 Thread 'Dan Kortschak' via golang-nuts
On Thu, 2022-09-22 at 00:58 +0100, Rory Campbell-Lange wrote: > interface conversion: *zip.checksumReader is not io.ReadSeeker: > missing method Seek > > Advice on how to rectify this would be gratefully received. Would it be acceptable to conditionally copy the reader's contents into a buffer

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-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] 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] 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] Library for printing a struct as a compiler recognized version

2022-08-16 Thread 'Dan Kortschak' via golang-nuts
On Mon, 2022-08-15 at 21:23 -0700, John wrote: > Thank you everyone who responded.  Gave utter a look and its pretty > decent.  I found litter a bit more developed around the circular > reference area.  But both were great suggestions and just what I was > looking for. I would be careful with

Re: [go-nuts] Library for printing a struct as a compiler recognized version

2022-08-15 Thread 'Dan Kortschak' via golang-nuts
On Mon, 2022-08-15 at 07:26 -0700, John wrote: > I know we have plenty of pretty printing out there, but i'm looking > for a package that can print the Go representation of a Struct out to > screen. > > So given: > > var x := { >   A: "hello" > } > > someLib.Print(x) > > I get: > > { >   A:

Re: [go-nuts] Preemptive interfaces in Go

2022-08-10 Thread 'Dan Kortschak' via golang-nuts
On Wed, 2022-08-10 at 11:17 -0700, Mike Schinkel wrote: > In my experience having control over the implementation is not a > black-and-white thing, unless you are the sole developer on a > project. This also brings in the consideration of that if you have complete control over the implementation,

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

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

[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] 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] 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-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] 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] 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] 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"),

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

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,

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

  1   2   3   4   5   6   7   >