Re: [go-nuts] Nil pointer panic that should be impossible

2024-03-25 Thread 'Brian Candler' via golang-nuts
And as Axel's own reproducer shows, even having two threads reading and writing the same *variable* which points to a string can result in indeterminate behaviour, since a string is really a struct containing two parts (a pointer and a len). You're not mutating the string itself, but you are

Re: [go-nuts] io.Reader can return (n, err), both non-zero

2024-03-25 Thread Tamás Gulácsi
I don't really get it. The current documentation says that bespite err!=nil, some data may be read (n!=0). If one obeys this rule, then it will consume the data, then handle the error. If we change then io.Reader's documentation (and all std lib implementations)... Ok, now I may be

Re: [go-nuts] Nil pointer panic that should be impossible

2024-03-25 Thread 'Axel Wagner' via golang-nuts
TBQH the word "mutable" doesn't make a lot of sense in Go (even though the spec also calls strings "immutable"). Arguably, *all* values in Go are immutable. It's just that all *pointers* in Go allow to modify the referenced variables - and some types allow you to get a pointer to a shared

Re: [go-nuts] Nil pointer panic that should be impossible

2024-03-25 Thread 'Lirong Wang' via golang-nuts
Wow, i am from other language and i thought `string` is immutable or something like that, so thread-safe for this operation. learned something new!!! Thanks On Thursday, March 21, 2024 at 11:42:24 PM UTC+8 Ethan Reesor wrote: > I hadn't used the race detector before. I do see a race warning

Re: [go-nuts] io.Reader can return (n, err), both non-zero

2024-03-25 Thread Diego Joss
Hi On Thu, 21 Mar 2024 at 19:23, 'Christian Stewart' via golang-nuts < golang-nuts@googlegroups.com> wrote: > When sending Read() via an RPC call or traversing locks, it is > significantly faster to return EOF in the same call as returning the rest > of the available data, than to call Read a

Re: [go-nuts] GO111MODULE=off go get deprecated?

2024-03-23 Thread Jeffery Carr
On Tuesday, March 5, 2024 at 9:29:58 AM UTC-6 Bryan C. Mills wrote: The simplest way to download Go dependencies for code review and debugging is to run `go mod vendor` in your module or (newly added) `go work vendor` in your workspace. Also note that `go mod download -json` and `go list -m

[go-nuts] New goroutine to immediately acquire the lock when Lock in starving mode?

2024-03-23 Thread Wen Wei
Lock always calls runtime_SemacquireMutex(, queueLifo, 1) -> semacquire1 when in starving mode. ```go // src/runtime/sema.go func semacquire1(addr *uint32, lifo bool, profile semaProfileFlags, skipframes int, reason waitReason) { gp := getg() if gp != gp.m.curg { throw("semacquire not on the G

[go-nuts] Context Deadline exceeded and WebSocket Url timeout issue

2024-03-22 Thread Ajay Sharma
I want to create pdf from a page and I am using chromedp to capture inner html from url, it takes 3-4 seconds to capture html from url Now I used this functionality in cron for sending pdf to the customer We have 25000 merchants and every

Re: [go-nuts] Nillable basic types?

2024-03-21 Thread Mike Schinkel
Hi Axel, Thank you for that link. I had not seen it before, but it is rather insightful. -Mike On Wednesday, March 20, 2024 at 10:29:20 AM UTC-4 Axel Wagner wrote: FWIW I believe (as Brian sort of points out) this proposal is fully subsumed under #57644

Re: [go-nuts] Discussion on runtime/compiler meeting: Struct packing/reordering

2024-03-21 Thread Ian Lance Taylor
‪On Thu, Mar 21, 2024 at 4:47 PM ‫محمد بومنذر‬‎ wrote:‬ > > I have been following the Go Runtime and Compiler team meeting notes for a > while. In the recent notes, I noticed something that got my attention > regarding memory layout optimization for structures. >

[go-nuts] Discussion on runtime/compiler meeting: Struct packing/reordering

2024-03-21 Thread محمد بومنذر
Hello, I have been following the Go Runtime and Compiler team meeting notes for a while. In the recent notes, I noticed something that got my attention regarding memory layout optimization for structures. https://github.com/golang/go/issues/43930#issuecomment-2009816508 I'm working on some

Re: [go-nuts] io.Reader can return (n, err), both non-zero

2024-03-21 Thread 'Christian Stewart' via golang-nuts
When sending Read() via an RPC call or traversing locks, it is significantly faster to return EOF in the same call as returning the rest of the available data, than to call Read a second time to get the EOF. It's not that hard to handle the EOF semantics. Yes, you have to know what io.EOF means.

Re: [go-nuts] io.Reader can return (n, err), both non-zero

2024-03-21 Thread Harri L
+1 I’d love to hear more about the motivation behind the io.EOF as an error. And why select a strategy to prefer *no* *discriminated unions* for the error results? Why transport non-error information in error values (io.EOF, 'http.ErrServerClosed)? “Normal” vs. “error” [control flow] is a

Re: [go-nuts] Nil pointer panic that should be impossible

2024-03-21 Thread Ethan Reesor
I hadn't used the race detector before. I do see a race warning for (*URL).String() among an embarrassing number of other results. I'm going to update (*URL).String() to use atomic.Pointer to remove the race. Thanks, Ethan On Thu, Mar 21, 2024 at 8:59 AM 'Axel Wagner' via golang-nuts <

Re: [go-nuts] Nil pointer panic that should be impossible

2024-03-21 Thread 'Axel Wagner' via golang-nuts
On Thu, Mar 21, 2024 at 2:48 PM 王李荣 wrote: > hi Axel, > > is not modifying `u.memoize.str` thread-safe? the len and the data point > should become visible at same time? > What makes you think that? To be clear, there are no benign data races. Even a data-race on a variable smaller than a word

Re: [go-nuts] Nil pointer panic that should be impossible

2024-03-21 Thread 王李荣
hi Axel, is not modifying `u.memoize.str` thread-safe? the len and the data point should become visible at same time? 在2024年3月16日星期六 UTC+8 06:29:06 写道: > Have you tried running the code with the race detector enabled? I suspect > that you are concurrently modifying `u.memoize.str` by

Re: [go-nuts] Re: 'go run hello.go' taking ~30 seconds on windows

2024-03-20 Thread Larry Clapp
I found this webpage from MS which talks about configuring Windows Defender. https://support.microsoft.com/en-us/windows/turn-off-defender-antivirus-protection-in-windows-security-99e6004f-c54c-8509-773c-a4d776b77960 I'm running a Windows 10 VM via VirtualBox on a MacBookPro. I have my $HOME

Re: [go-nuts] Nillable basic types?

2024-03-20 Thread 'Axel Wagner' via golang-nuts
FWIW I believe (as Brian sort of points out) this proposal is fully subsumed under #57644 . Under that proposal, the proposed type `int | nil` would be spelled `interface{ int }`. The other syntactical constructs are, as far as I can tell, identical -

Re: [go-nuts] Nillable basic types?

2024-03-20 Thread Mike Schinkel
On Wednesday, March 20, 2024 at 5:47:00 AM UTC-4 Brian Candler wrote: If you change fundamental things like this in the language, then you'll suggesting turning Go into something that looks like Rust. In which case, you may as well just use Rust. Agreed. Which is why I was asking if using

Re: [go-nuts] Nillable basic types?

2024-03-20 Thread Mike Schinkel
On Wednesday, March 20, 2024 at 5:31:08 AM UTC-4 Brian Candler wrote: It's in the very first post that opened this thread, under the heading "## Summary". I did in-fact miss it. Thank you for pointing to it. -Mike -- You received this message because you are subscribed to the Google

Re: [go-nuts] Nillable basic types?

2024-03-20 Thread 'Brian Candler' via golang-nuts
I got the impression the proposal was motivated by scalars that did not currently allow `nil` values Under the heading "Alternatives and why they're bad" he describes some ways this is currently dealt with - such as the common idiom of returning or passing a pointer to a value, instead of a

Re: [go-nuts] Nillable basic types?

2024-03-20 Thread 'Brian Candler' via golang-nuts
On Wednesday 20 March 2024 at 09:01:43 UTC Mike Schinkel wrote: Your comments made me go back and read the whole thing, but I was unable to find a list of enumerated objectives, and I did not find the text you quoted. Did I miss it somehow? It's in the very first post that opened this

Re: [go-nuts] Nillable basic types?

2024-03-20 Thread Mike Schinkel
On Wednesday, March 20, 2024 at 4:14:27 AM UTC-4 Brian Candler wrote: When you say "var x NillableUint8" then you've just declared a variable of an interface type, and interface types are already nilable, so there's no need for "| nil" in the type! Well, I was thinking of 1.) explicitness

Re: [go-nuts] Using new variable or updating existing variable in a loop

2024-03-20 Thread Mohamad Rostami
Thanks @kurtis, I actually have both functions without fmt print function, so no allocation is happening. I also did compare assembly codes with your command, and can confirm both are equal. go 1.21.0 darwin/arm64 On Tuesday, March 19, 2024 at 11:20:03 PM UTC+1 Kurtis Rader wrote: >

Re: [go-nuts] Nillable basic types?

2024-03-20 Thread 'Brian Candler' via golang-nuts
When you say "var x NillableUint8" then you've just declared a variable of an interface type, and interface types are already nilable, so there's no need for "| nil" in the type! https://go.dev/play/p/f54akG65qJ3 https://go.dev/play/p/Jmtlta0h9m9 // generic version It's a perfectly valid way

Re: [go-nuts] Nillable basic types?

2024-03-20 Thread Mike Schinkel
> On Mar 19, 2024, at 2:43 PM, Daniel Lepage wrote: > > I'm not proposing that *any* value be made nillable, I'm proposing the > explicit syntax > > var x uint8 | nil > > that would create a nillable uint8. A variable of type `byte` would still > only take up one byte; a variable of type

Re: [go-nuts] io.Reader can return (n, err), both non-zero

2024-03-19 Thread Nigel Tao
On Wed, Mar 20, 2024 at 2:13 PM Ian Lance Taylor wrote: > Some earlier discussions: > > https://groups.google.com/g/golang-nuts/c/b78eRMOS0FA/m/jq8lAQhenaoJ > https://groups.google.com/g/golang-nuts/c/WGYJx3ICCW4/m/1L0WcN8eqmkJ > > See in particular this message from Russ: >

Re: [go-nuts] io.Reader can return (n, err), both non-zero

2024-03-19 Thread Ian Lance Taylor
On Tue, Mar 19, 2024 at 6:40 PM Nigel Tao wrote: > > The ubiquitous io.Reader interface's Read method returns a (int, > error). Surprisingly (for programmers coming from other languages with > a built-in or idiomatic Result type), it's possible for both > return values to be non-zero. There's

[go-nuts] io.Reader can return (n, err), both non-zero

2024-03-19 Thread Nigel Tao
The ubiquitous io.Reader interface's Read method returns a (int, error). Surprisingly (for programmers coming from other languages with a built-in or idiomatic Result type), it's possible for both return values to be non-zero. There's (often overlooked??) commentary in https://pkg.go.dev/io#Reader

Re: [go-nuts] Nillable basic types?

2024-03-19 Thread Patrick Smith
On Tue, Mar 19, 2024 at 11:44 AM Daniel Lepage wrote: > I'm not proposing that *any* value be made nillable, I'm proposing the > explicit syntax > > var x uint8 | nil > > that would create a nillable uint8. A variable of type `byte` would still > only take up one byte; a variable of type `byte |

Re: [go-nuts] Using new variable or updating existing variable in a loop

2024-03-19 Thread Kurtis Rader
Also, if you tell the compiler to report memory allocations you'll see something like this: ./x.go:10:13: inlining call to fmt.Printf ./x.go:18:13: inlining call to fmt.Printf ./x.go:7:6: moved to heap: h ./x.go:10:13: ... argument does not escape ./x.go:17:3: moved to heap: h ./x.go:18:13: ...

Re: [go-nuts] Using new variable or updating existing variable in a loop

2024-03-19 Thread Kurtis Rader
I would start by building it with inlining disabled and assembler output enabled. Then compare the assembly code for main.A and main.B. go build -gcflags 'all=-l -S' x.go 2>y On Tue, Mar 19, 2024 at 1:12 PM Mohamad Rostami wrote: > Well, I used runtime runtime.MemStats StackInuse. > I don't

Re: [go-nuts] Using new variable or updating existing variable in a loop

2024-03-19 Thread Mohamad Rostami
Well, I used runtime runtime.MemStats StackInuse. I don't have much knowledge about compiler optimization. But to make it clear for myself: considering these 2 functions: //go:noinline func A() { var h int for i := 0; i < 1e5; i++ { h = i _ = h fmt.Printf("%+v\n", ) }

Re: [go-nuts] Nillable basic types?

2024-03-19 Thread Daniel Lepage
*From Jan Mercl: * > To represent all those values and the new possibility > of the value being nil, we need 257 distinct values. But that does not > fit 8 in bits anymore. However, changing the size and/or the bit > representation of such a variable is observable, making it not >

Re: [go-nuts] Using new variable or updating existing variable in a loop

2024-03-19 Thread Ian Lance Taylor
On Tue, Mar 19, 2024 at 9:36 AM Mohamad Rostami wrote: > > I've seen in many places in go source code re-declaring a variable with the > same name. > e.g: > for i < j { >h := ... > } > Instead of > var h int > for i < j { >h = ... > } > > So I did a benchmark to check the differences. I

[go-nuts] Using new variable or updating existing variable in a loop

2024-03-19 Thread Mohamad Rostami
Hi, I've seen in many places in go source code re-declaring a variable with the same name. e.g: for i < j { h := ... } Instead of var h int for i < j { h = ... } So I did a benchmark to check the differences. I didn't find any performance related differences, but in terms of Stack

Re: [go-nuts] Nillable basic types?

2024-03-19 Thread Jeremy French
I understand the problem you are trying to solve, and it's valid, I think. But this solutions "feels" bad and very un-Go-like. Usable zero values is a feature in Go. Whether you agree with that or not, it's a selling feature of the language and clearly something that was/is important to the

Re: [go-nuts] Nillable basic types?

2024-03-18 Thread 'Brian Candler' via golang-nuts
I like Go because it's relatively simple and low-level, like C, except with things like garbage collection and channels integrated. If Go were to have "| nil" types then the internal representation of such variables would have to be something like this: type Maybe[T any] struct { Value T

Re: [go-nuts] Nillable basic types?

2024-03-18 Thread Jan Mercl
On Mon, Mar 18, 2024 at 4:41 AM Daniel Lepage wrote: > This change would be entirely backward-compatible ... Let's consider, for example, the type uint8, aka byte. A variable of type byte is specified* to occupy 8 bits of memory and has 256 possible values. To represent all those values and the

[go-nuts] Nillable basic types?

2024-03-17 Thread Daniel Lepage
Hey everyone, I've been thinking for a while now about the advantages of nillable types, especially for basic types, and I'm interested in making an official language proposal. I'd love to know what the rest of the community thinks about it, and if this discussion has been had before (I found

Re: [go-nuts] Nil pointer panic that should be impossible

2024-03-15 Thread 'Axel Wagner' via golang-nuts
Have you tried running the code with the race detector enabled? I suspect that you are concurrently modifying `u.memoize.str` by calling `u.String()` from multiple goroutines. And the non-zero length of the string header written by one goroutine becomes visible to the other one, before the

[go-nuts] Nil pointer panic that should be impossible

2024-03-15 Thread Ethan Reesor
>From this CI job : panic: runtime error: invalid memory address or nil pointer dereference [signal SIGSEGV: segmentation violation code=0x1 addr=0x0 pc=0x51d8b7] goroutine 1589381 [running]: strings.EqualFold({0xc000beec20?,

[go-nuts] Re: VsCode syntax highlighting for tmpl files

2024-03-15 Thread Soyaib Zihad
"files.associations": { "*.tmpl": "html" } add this to settings.json in vs-code and life is good. On Sunday, October 13, 2019 at 9:49:58 PM UTC+6 Andreas wrote: > the drawback is when I enter in .gohtml file > > ```{{``` > > then vscode auto-copletes it with > > ```}}}``` > > did you get the

[go-nuts] Re: go test -coverpkg=$LIST ... failing with exit code

2024-03-14 Thread 'TheDiveO' via golang-nuts
Looking and looking again, at least I spotted a lonely "open /tmp/go-build/covmeta: no such file or directory" error message. This now finally matches https://github.com/golang/go/issues/65653 and using gotip finally succeeds correctly. -- You received this message because you are

Re: [go-nuts] debug/gosym.PCToLine breaks on cgo enabled binaries

2024-03-14 Thread 'Grant Seltzer Richman' via golang-nuts
On Wednesday, March 13, 2024 at 4:37:31 PM UTC-4 Ian Lance Taylor wrote: On Wed, Mar 13, 2024 at 8:04 AM 'Grant Seltzer Richman' via golang-nuts wrote: > > I've been using the `Table.PCToLine` method to resolve program counters (extracted via bpf) into functions with their file names and

Re: [go-nuts] GO111MODULE=off go get deprecated?

2024-03-13 Thread Jeffery Carr
On Thu, Mar 7, 2024 at 4:28 AM Jan Mercl <0xj...@gmail.com> wrote: > jnml@e5-1650:~/tmp/get$ GOPATH=$(pwd) GO111MODULE=auto go get -v > modernc.org/sqlite > > jnml@e5-1650:~/tmp/get$ ls pkg/mod/ > cache github.com golang.org modernc.org > Interesting, it does indeed pull the pkg/mod, but

Re: [go-nuts] GO111MODULE=off go get deprecated?

2024-03-13 Thread Jeffery Carr
On Mon, Mar 11, 2024 at 10:05 AM roger peppe wrote: > It's not quite what you're after, but FWIW the gohack command ( > github.com/rogpeppe/gohack) knows enough to download arbitrary Go modules > including the VCS checkout. You might find it useful, I guess. > Okay, yes, I'm only 5 years late

Re: [go-nuts] debug/gosym.PCToLine breaks on cgo enabled binaries

2024-03-13 Thread Ian Lance Taylor
On Wed, Mar 13, 2024 at 8:04 AM 'Grant Seltzer Richman' via golang-nuts wrote: > > I've been using the `Table.PCToLine` method to resolve program counters > (extracted via bpf) into functions with their file names and line numbers. > > It appears that this breaks when i'm testing it on a binary

Re: [go-nuts] Why can't I use an interface which needs another interface inside of it

2024-03-13 Thread Mike Schinkel
> On Mar 13, 2024, at 10:27 AM, Brian Hatfield wrote: > > Client.GetChild() must return GetChilder, not Child. Actually, Client.GetChild() must return b.GetDataer, not b.GetChilder, but the example is a mind bender so it was easy to get wrong. I only got it correct by testing the code and

Re: [go-nuts] Why can't I use an interface which needs another interface inside of it

2024-03-13 Thread Jason Phillips
Regardless, that's the reason what you've attempted doesn't work. It has its own entry in the Go FAQ: https://go.dev/doc/faq#covariant_types On Wednesday, March 13, 2024 at 1:00:34 PM UTC-4 Rodrigo Araujo wrote: > 'Cause this dependency makes code more "rigid". A refactor in an isolated >

[go-nuts] Re: go test -coverpkg=$LIST ... failing with exit code

2024-03-13 Thread Jeremy French
I don't have any insight in trouble-shooting your exact issue, but I too would like a simple, reliable way to exclude packages from -coverpkg=./... Feels like relying on shell scripts (which is what a google search recommends) is a) fragile, and b) not particularly cross-platform. On Tuesday,

Re: [go-nuts] Why can't I use an interface which needs another interface inside of it

2024-03-13 Thread Rodrigo Araujo
'Cause this dependency makes code more "rigid". A refactor in an isolated package would let to change other packages. Also makes testing more difficult. It is kind of described here: https://go.dev/wiki/CodeReviewComments#interfaces Em qua., 13 de mar. de 2024 às 13:41, burak serdar escreveu: >

Re: [go-nuts] Why can't I use an interface which needs another interface inside of it

2024-03-13 Thread burak serdar
On Wed, Mar 13, 2024 at 10:31 AM Rodrigo Araujo wrote: > > Do you mean b.GetChilder? In this case, package A will depend on package B > and I don't think this is a good approach. Why would it not be a good approach? You have a package declaring interfaces, and if you have another package using

Re: [go-nuts] Why can't I use an interface which needs another interface inside of it

2024-03-13 Thread Rodrigo Araujo
Do you mean b.GetChilder? In this case, package A will depend on package B and I don't think this is a good approach. Em qua., 13 de mar. de 2024 às 11:28, Brian Hatfield escreveu: > Client.GetChild() must return GetChilder, not Child. > > On Wed, Mar 13, 2024 at 10:02 AM Rodrigo Araujo wrote:

[go-nuts] debug/gosym.PCToLine breaks on cgo enabled binaries

2024-03-13 Thread 'Grant Seltzer Richman' via golang-nuts
I've been using the `Table.PCToLine` method to resolve program counters (extracted via bpf) into functions with their file names and line numbers. It appears that this breaks when i'm testing it on a binary that has cgo enabled. It does not fix it by compiling the binary statically. Another

Re: [go-nuts] Why can't I use an interface which needs another interface inside of it

2024-03-13 Thread Brian Hatfield
Client.GetChild() must return GetChilder, not Child. On Wed, Mar 13, 2024 at 10:02 AM Rodrigo Araujo wrote: > Given the code bellow, I'm trying to keep my packages completely > separated, without knowing each other, but the code doesn't work. I just > can get it running when I define (or use)

[go-nuts] Why can't I use an interface which needs another interface inside of it

2024-03-13 Thread Rodrigo Araujo
Given the code bellow, I'm trying to keep my packages completely separated, without knowing each other, but the code doesn't work. I just can get it running when I define (or use) an interface from one package inside code of the other package. Here is the error: *cannot use client (variable

Re: [go-nuts] Can't figure out how to create an All() iter.Seq[T] method

2024-03-13 Thread 'Mark' via golang-nuts
Thank you, that solved the problem. On Wednesday, March 13, 2024 at 1:22:06 PM UTC Sebastien Binet wrote: > hi Mark, > > On Wed Mar 13, 2024 at 13:32 CET, 'Mark' via golang-nuts wrote: > > I've been trying to learn how to create an `All() iter.Seq[T]` method > > for a > > simple set type (a map

Re: [go-nuts] Can't figure out how to create an All() iter.Seq[T] method

2024-03-13 Thread Sebastien Binet
hi Mark, On Wed Mar 13, 2024 at 13:32 CET, 'Mark' via golang-nuts wrote: > I've been trying to learn how to create an `All() iter.Seq[T]` method > for a > simple set type (a map wrapper): > > playground > > It won't work in the playground of course, but

[go-nuts] Can't figure out how to create an All() iter.Seq[T] method

2024-03-13 Thread 'Mark' via golang-nuts
I've been trying to learn how to create an `All() iter.Seq[T]` method for a simple set type (a map wrapper): playground It won't work in the playground of course, but when I do: `GOEXPERIMENT=rangefunc go run .` using Go 1.22 I get this error: ```

[go-nuts] Re: range-over-func has two more alloc than direct-call-func Why?

2024-03-13 Thread 'qiulaidongfeng' via golang-nuts
I got the information ./main_test.go:23:3: func literal escapes to heap: ./main_test.go:23:3: flow: {heap} = &{storage for func literal}: ./main_test.go:23:3: from func literal (spill) at ./main_test.go:23:3 ./main_test.go:23:3: from .autotmp_3(func literal) (call parameter) at

[go-nuts] go test -coverpkg=$LIST ... failing with exit code

2024-03-12 Thread 'TheDiveO' via golang-nuts
Dear Gophers, I'm struggling with "go test -coverpkg=XXX ... ./... -args -test.gocoverdir" returning non-zero exit codes, albeit all tests are passing. It might well be that I'm not really yet understanding how "go test -coverpkg=" is supposed to work. As illustrated below, I don't want to

[go-nuts] Re: range-over-func has two more alloc than direct-call-func Why?

2024-03-12 Thread peterGo
qiulaidongfeng, -gcflags=-m=2 peter On Tuesday, March 12, 2024 at 7:06:21 AM UTC-4 qiulaidongfeng wrote: > For the following code > > > https://go.dev/play/p/ynn7ihKXrp0?v=gotip > > > I got the benchmark > > > BenchmarkBelow3-16 9523 147772 ns/op 17 B/op 2 allocs/op > >

[go-nuts] range-over-func has two more alloc than direct-call-func Why?

2024-03-12 Thread 'qiulaidongfeng' via golang-nuts
For the following code https://go.dev/play/p/ynn7ihKXrp0?v=gotip I got the benchmark BenchmarkBelow3-16 9523 147772 ns/op 17 B/op 2 allocs/op BenchmarkBelow3direct-16 1 107335 ns/op 0 B/op 0 allocs/op range-over-func has two more alloc than direct-call-func. Why? -- You received

[go-nuts] Re: Why is more memory being used when encoding a slice of structs with smaller length

2024-03-11 Thread peterGo
Also posted on Stack Overflow: Why is more memory being used when encoding a slice of structs with smaller length https://stackoverflow.com/questions/78136093/why-is-more-memory-being-used-when-encoding-a-slice-of-structs-with-smaller-leng On Monday, March 11, 2024 at

[go-nuts] Why is more memory being used when encoding a slice of structs with smaller length

2024-03-11 Thread Kwaku Biney
Go version go version devel go1.23-e8b5bc63be linux/amd64 When using binary.Write for encoding a slice of structs, I encountered some weird behaviour where memory allocations in a particular path was more than I expected. I wrote some benchmarks in the standard library's encoding/binary

Re: [go-nuts] GO111MODULE=off go get deprecated?

2024-03-11 Thread roger peppe
It's not quite what you're after, but FWIW the gohack command ( github.com/rogpeppe/gohack) knows enough to download arbitrary Go modules including the VCS checkout. You might find it useful, I guess. For example: % gohack get -vcs golang.org/x/mod creating golang.org/x/mod@v0.16.0

[go-nuts] Re: Named pipes blocking with O_NONBLOCK on Mac

2024-03-11 Thread Kwaku Biney
I think you put this issue on the Go issue board? https://github.com/golang/go/issues/66239 Seems like the bug has been confirmed or at least it's being looked at On Monday, March 11, 2024 at 2:04:19 PM UTC Jay Goel wrote: > Hello, > > I believe there is a bug where, on Mac, reading a named

[go-nuts] Why is more memory being used when encoding a slice of structs with smaller length

2024-03-11 Thread Kwaku Biney
When using `binary.Write` for encoding a slice of structs, I encountered some weird behaviour where memory allocations in a particular path was more than I expected. I wrote some benchmarks in the standard library's encoding/binary package to demonstrate this. func

[go-nuts] Named pipes blocking with O_NONBLOCK on Mac

2024-03-11 Thread Jay Goel
Hello, I believe there is a bug where, on Mac, reading a named pipe with O_NONBLOCK is blocking on Read(). I am not able to reproduce this on Linux. This example is on go version go1.22.1 darwin/arm64, and I am running an M1 2020 macbook with OS version 12.5 (21G72). I believe there is some

Re: [go-nuts] govulncheck

2024-03-11 Thread Volker Dobler
What exactly beside the information in https://go.dev/blog/govulncheck and especially https://go.dev/doc/tutorial/govulncheck do you want to discuss? V On Monday 11 March 2024 at 00:49:17 UTC+1 Colton Freeman wrote: > Disregard. Figured out the tool (a little better). Would still love to >

Re: [go-nuts] govulncheck

2024-03-10 Thread Colton Freeman
Disregard. Figured out the tool (a little better). Would still love to chat with some that has in depth experience with it though. On Fri, Mar 8, 2024, 1:36 PM Colton Freeman wrote: > good day all, > i am not a developer and have just recently stumbled upon the > `govulncheck` tool from golang.

[go-nuts] Why is more memory being used when encoding a slice of structs with smaller length

2024-03-10 Thread Kwaku Biney
When using `binary.Write` for encoding a slice of structs, I encountered some weird behaviour where memory allocations in a particular path was more than I expected. I wrote some benchmarks in the standard library's encoding/binary package to demonstrate this. func

Re: [go-nuts] How To Reduce Json Marshalling Time

2024-03-10 Thread Robert Engels
Apologies.On Mar 9, 2024, at 1:16 PM, Ian Lance Taylor wrote:This thread has gotten heated.  I think it's time to move on to different topics and give this discussion a rest.  Thanks.Ian -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To

[go-nuts] Issue with golang.design/x/clipboard

2024-03-09 Thread Arie van Wingerden
See my code attached! My issue is that, after writing to the clipboard, I can only read the string I wrote back during the period I "sleep" after the write. If I do not sleep, the clipboard immediately reverts to "empty". Am I doing something wrong here? TIA Arie -- You received this

Re: [go-nuts] How To Reduce Json Marshalling Time

2024-03-09 Thread Ian Lance Taylor
This thread has gotten heated. I think it's time to move on to different topics and give this discussion a rest. Thanks. Ian -- 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] How To Reduce Json Marshalling Time

2024-03-09 Thread Mike Schinkel
On Saturday, March 9, 2024 at 10:16:12 AM UTC-5 Robert Engels wrote: When I went to the github site the OP linked it seemed to me the original question was not genuine and ... Since the OP of this thread did not link anything, I assume you by "OP" you are referring to my comments on the

Re: [go-nuts] How To Reduce Json Marshalling Time

2024-03-09 Thread 'Brian Candler' via golang-nuts
Perhaps it would be helpful to give some concrete figures for the real-world application. "the response time of Go API is higher than PHP" - how much? Are we talking, say, 1.2ms versus 1ms? Or 10ms versus 1ms? Is this testing between a client and server adjacent on the same LAN, or is the

Re: [go-nuts] How To Reduce Json Marshalling Time

2024-03-08 Thread Mike Schinkel
On Saturday, March 9, 2024 at 12:16:51 AM UTC-5 Robert Engels wrote: My guess is that most applications are decoding 25gb json files with any regularity. Even transferring 25 GB over the fastest of networks takes 20 secs? So that reduces the cost to less than 10%??? How about rather than

Re: [go-nuts] How To Reduce Json Marshalling Time

2024-03-08 Thread Robert Engels
My guess is that most applications are decoding 25gb json files with any regularity. Even transferring 25 GB over the fastest of networks takes 20 secs? So that reduces the cost to less than 10%???The test isn’t doing anything with the decoded json - maybe Go is 1000% faster in that. This is

Re: [go-nuts] How To Reduce Json Marshalling Time

2024-03-08 Thread Mike Schinkel
Hi Robert, Thanks for the reply. I decided to run a quick benchmark so I compared Go 1.22's *json.UnMarshal(any)* using an *any* type with PHP 8.3.2's *json_decode()* and found that PHP's option is 85% faster for a ~25Mb JSON file. Optimizing it with a *struct* I was able to get Go down to

Re: [go-nuts] How To Reduce Json Marshalling Time

2024-03-08 Thread Robert Engels
Related, 30k of anything is largely meaningless for modern hardware in terms of cpu processing - where billions of operations a second is the norm. On Mar 8, 2024, at 8:55 PM, Robert Engels wrote:The point I was trying to make - maybe unclear - is that it is doubtful any raw performance

Re: [go-nuts] How To Reduce Json Marshalling Time

2024-03-08 Thread Robert Engels
The point I was trying to make - maybe unclear - is that it is doubtful any raw performance differences between PHP and Go in terms of json encoding/decoding would be noticeable- unless it was a hft/hpc system which would be doubtful given that the original system was PHP. So if there is

Re: [go-nuts] How To Reduce Json Marshalling Time

2024-03-08 Thread Mike Schinkel
Hi Robert, I am now confused. While your original reply to this thread made perfect sense to me, your follow up for the purposes of clarification had the opposite effect, at least for me. I am not clear the point you are trying to make. You mention the difference between compiled and

Re: [go-nuts] How To Reduce Json Marshalling Time

2024-03-08 Thread Robert Engels
Just to be clear for others - from a raw cpu performance perspective when looking at a typical application in whole - there is very little performance difference between compiled and even GC platforms- interpreted can lag behind a bit - but in almost all cases over the web it is IO

Re: [go-nuts] How To Reduce Json Marshalling Time

2024-03-08 Thread Mike Schinkel
Hi Pragya, While Robert Engles is probably correct in identifying your bottleneck, if it does turn out to be slow JSON parsing here are a few things you can look at . 1. You mention you have to use a map because of response keys not

Re: [go-nuts] How To Reduce Json Marshalling Time

2024-03-08 Thread Robert Engels
It is highly unlikely that the Go marshaling is the cause. I’m guessing you are probably not using a buffered output stream. PHP is written in C but depending on what you are doing it is either a script or calling out to another process (afaik) On Mar 8, 2024, at 2:35 PM, pragya singh

[go-nuts] govulncheck

2024-03-08 Thread Colton Freeman
good day all, i am not a developer and have just recently stumbled upon the `govulncheck` tool from golang. i am curious how accurate this tool is and if it should be used in a scan report for vulnerabilities? do we need to run this on the main.go and reference the go.mod file in the project?

[go-nuts] How To Reduce Json Marshalling Time

2024-03-08 Thread pragya singh
Hi, "I am facing an issue in my Go code. I converted my read API from PHP to Go, but the response time of Go API is higher than PHP. We are returning the response in JSON format, and the response contains around 30k keys, which is taking too much time in JSON marshaling. We are adding all the

Re: [go-nuts] rsc.io/script: How to contribute?

2024-03-08 Thread twp...@gmail.com
Many thanks for the response Russ. It's clear I should stick with testscript for now. Regards, Tom On Friday, March 8, 2024 at 3:04:10 AM UTC+1 Russ Cox wrote: > Hi all, > > I published rsc.io/script for people to play with, to support my testing > talk .

Re: [go-nuts] rsc.io/script: How to contribute?

2024-03-07 Thread Russ Cox
Hi all, I published rsc.io/script for people to play with, to support my testing talk . For now it is on a back burner - I get so much GitHub mail that I cannot keep up with all the notifications, so I hadn't seen the activity there. Perhaps at some point we

Re: [go-nuts] Re: rsc.io/script: How to contribute?

2024-03-07 Thread twp...@gmail.com
github.com/rogpeppe/go-internal/testscript is absolutely wonderful. I've been using it successfully for several years and am the #4 contributor to the project. My only complaint would be that it sometimes takes a few months for changes to be merged and the release cycle is infrequent, meaning

Re: [go-nuts] Re: rsc.io/script: How to contribute?

2024-03-07 Thread Eli Bendersky
On Thu, Mar 7, 2024 at 5:44 AM twp...@gmail.com wrote: > Thanks, but I'm already heavily invested in testscript with over 10K lines > of scripts and a lot of custom configuration, and commander-cli/commander > clearly lacks functionality I need. > OOC, is there anything wrong with

[go-nuts] Re: rsc.io/script: How to contribute?

2024-03-07 Thread twp...@gmail.com
Thanks, but I'm already heavily invested in testscript with over 10K lines of scripts and a lot of custom configuration, and commander-cli/commander clearly lacks functionality I need. On Thursday, March 7, 2024 at 2:47:03 AM UTC+1 Ajay Kidave wrote: > I have had a good experience using >

Re: [go-nuts] GO111MODULE=off go get deprecated?

2024-03-07 Thread Jan Mercl
On Sun, Mar 3, 2024 at 10:25 PM Jeffery Carr wrote: > Has this been deprecated or maybe it is broken in debian sid, but: > > bash$ GO111MODULE=off go get -v go.wit.com/apps/test > go: modules disabled by GO111MODULE=off; see 'go help modules' > basj$ go version > go version go1.22.0 linux/amd64

[go-nuts] Re: rsc.io/script: How to contribute?

2024-03-06 Thread Ajay Kidave
I have had a good experience using https://github.com/commander-cli/commander for testing CLI commands. It uses a yaml file for test config. I generally avoid yaml but the commander config format is easy to work with. Never used script, the state saving between commands feature might be

Re: [go-nuts] GO111MODULE=off go get deprecated?

2024-03-06 Thread 'Christian Stewart' via golang-nuts
On Wed, Mar 6, 2024 at 11:53 AM Jeffery Carr wrote: > On Sunday, March 3, 2024 at 5:46:13 PM UTC-6 Christian Stewart wrote: > Second, you can use "go work" to create a workspace with multiple go > modules in it, so that you can develop with them without having to > constantly update the go.mod

[go-nuts] Re: rsc.io/script: How to contribute?

2024-03-06 Thread twp...@gmail.com
*rsc.io/script On Wednesday, March 6, 2024 at 10:46:23 PM UTC+1 twp...@gmail.com wrote: > Internally, Go has a very nice package for integration testing > . > > Roger Peppe has been doing a

[go-nuts] rsc.io/script: How to contribute?

2024-03-06 Thread twp...@gmail.com
Internally, Go has a very nice package for integration testing . Roger Peppe has been doing a fantastic service by making it public and maintaining it as a community project at

Re: [go-nuts] GO111MODULE=off go get deprecated?

2024-03-06 Thread Jeffery Carr
On Sunday, March 3, 2024 at 5:46:13 PM UTC-6 Christian Stewart wrote: Firstly, you can reference the other repos and use the latest "master" version by writing "master" where the v verson is in the file, then use "go mod tidy" Second, you can use "go work" to create a workspace with

<    1   2   3   4   5   6   7   8   9   10   >