Re: [go-nuts] Bitmask is slower than modulo calculation

2024-05-12 Thread leon
Thank you so much. 2024年5月13日月曜日 12:58:09 UTC+9 Kurtis Rader: > On my Apple Studio system the difference in speed is barely measurable and > sometimes the bitmask implementation is faster: > > macpro ~/experiment > go run ring.go > 10 ops in 5092 ms > 10 ops in 5140 ms >

Re: [go-nuts] Bitmask is slower than modulo calculation

2024-05-12 Thread Kurtis Rader
On my Apple Studio system the difference in speed is barely measurable and sometimes the bitmask implementation is faster: macpro ~/experiment > go run ring.go 10 ops in 5092 ms 10 ops in 5140 ms macpro ~/experiment > go run ring.go 10 ops in 5080 ms 10 ops

Re: [go-nuts] Bitmask is slower than modulo calculation

2024-05-12 Thread robert engels
Use the Go benchmarking facilities, see https://dave.cheney.net/2013/06/30/how-to-write-benchmarks-in-go > On May 11, 2024, at 9:57 PM, leon wrote: > > I'm trying to prove an optimization technique for ring buffer is effective. > One of the technique is using bitmask instead of modulo to

[go-nuts] Bitmask is slower than modulo calculation

2024-05-11 Thread leon
I'm trying to prove an optimization technique for ring buffer is effective. One of the technique is using bitmask instead of modulo to calculate a wrap around. However, in my environment, modulo is slightly faster in a test where 1 billion items are enqueued /dequeued by a single goroutine.

[go-nuts] Re: VCS Stamping - How To Use It? How to debug failures?

2024-05-11 Thread Jason E. Aten
> how can developers debug and find the root cause? If it was me, I would start by going into the container (whatever the podman equivalent of docker exec -it containernumber bash) and try to run 'git status' or 'git log' and see why the git query is giving an error. You could also try strace

Re: [go-nuts] Permissions in ~/go/pkg

2024-05-10 Thread Ian Lance Taylor
On Fri, May 10, 2024 at 2:11 PM Tobias Klausmann wrote: > > On Fri, 10 May 2024, Ian Lance Taylor wrote: > > This is a choice made by Go. You can override with the -modcacherw > > option to "go build", "go test", "go install", and similar code. You > > can make that option the default by

[go-nuts] Re: var errors stdlib

2024-05-10 Thread 'Brian Candler' via golang-nuts
On Friday 10 May 2024 at 17:03:46 UTC+1 Sebastian Bogan wrote: Would something like the following work (and be less risky)?: type ConstError string func (e ConstError) Error() string { return string(e) } const ErrNotExist = ConstError("file does not exist") If you compare an error

Re: [go-nuts] Permissions in ~/go/pkg

2024-05-10 Thread Tobias Klausmann
Hi! On Fri, 10 May 2024, Ian Lance Taylor wrote: > This is a choice made by Go. You can override with the -modcacherw > option to "go build", "go test", "go install", and similar code. You > can make that option the default by setting GOFLAGS in the environment > or via "go env GOFLAGS=...". >

Re: [go-nuts] Permissions in ~/go/pkg

2024-05-10 Thread Ian Lance Taylor
On Fri, May 10, 2024 at 10:43 AM Tobias Klausmann wrote: > > I test and try a whole load of Go tools and libraries, and as a result, > my ~go/pkg dir quickly grows. While I'd love some kind of automatic > expiry for that cache, I am fine with just occasionally running rm-rf on > that dir myself.

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 =

[go-nuts] VCS Stamping - How To Use It? How to debug failures?

2024-05-10 Thread Adam Kaplan (He / Him / His)
My team recently started using podman and the UBI9 go-toolset image to containerize our golang apps [1]. We found that if our Dockerfile copied the entire source tree in (including the .git directory), `go build` would fail unless we set the `-buildvcs=false` flag [2]. Since this wasn't

[go-nuts] Permissions in ~/go/pkg

2024-05-10 Thread Tobias Klausmann
Hi! I test and try a whole load of Go tools and libraries, and as a result, my ~go/pkg dir quickly grows. While I'd love some kind of automatic expiry for that cache, I am fine with just occasionally running rm-rf on that dir myself. ... except it doesn't work. For some unclear reason, some of

[go-nuts] var errors stdlib

2024-05-10 Thread Sebastian Bogan
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 = os.ReadFile("./invalid") if !errors.Is(err, fs.ErrNotExist) { fmt.Println("is

[go-nuts] strange perf sample when trying to understand the cause of high minor page fault

2024-05-09 Thread 'Zhao Weng' via golang-nuts
Hi gophers, We have a web service running with high minor page fault and I'm trying to understand why. I start by using linux perf: ```bash sudo perf record -e minor-faults -c 1 -C 0-2 -ag -- sleep 15 sudo perf script > perf.out ``` and in the output file perf.out, I found many strange trace

[go-nuts] x/text Missing maintenance

2024-05-08 Thread mr....@gmail.com
I submitted CL to x/text, but no one seems to have any to review it at the moment. I also checked the recent CL for x/text. again, no one is taking care of it. text has a several year old problem that has been resolved by the corresponding CL, but has not been merged. I'd like to support if

RE: [go-nuts] Re: Slice conversion function not working on big endian platform

2024-05-08 Thread 'Pokala Srinivas' via golang-nuts
I am using generics here to work for other types as well, it 's not only for converting int32[] slice to int64[], it is generic function to work for any conversion like BytestoInt64/32/16/8, BytestoFloat32/64 etc. It is failing for other conversion like BytestoInt64 , BytestoFloat64 etc on

Re: [go-nuts] Re: Slice conversion function not working on big endian platform

2024-05-08 Thread 'Pokala Srinivas' via golang-nuts
There is typo mistake while entering, below is the code snippest: package main import (   "fmt"   "unsafe" ) type slice struct {   ptr unsafe.Pointer   len int   cap int } func Slice[To, From any](data []From) []To {   var zf From   var zt To   var s =

[go-nuts] Re: Slice conversion function not working on big endian platform

2024-05-08 Thread 'Brian Candler' via golang-nuts
That code doesn't even compile in go 1.22 or go.1.21: https://go.dev/play/p/mPCBUQizSVo ./prog.go:20:14: cannot convert unsafe.Pointer(s) (value of type unsafe.Pointer) to type []To What's the underlying requirement? In the test case it looks like you want to take a slice of int32's, in

[go-nuts] Slice conversion function not working on big endian platform

2024-05-08 Thread 'Srinivas Pokala' via golang-nuts
Hello gopher's, I have simple go program which convert slice of one type to slice of other type using go generics for handling all the supported types. Below is the code snippest for this: package main import "fmt" import "unsafe" type slice struct { ptr unsafe.Pointer len int

[go-nuts] [security] Go 1.22.3 and Go 1.21.10 are released

2024-05-07 Thread Cherry Mui
Hello gophers, We have just released Go versions 1.22.3 and 1.21.10, minor point releases. These minor releases include 2 security fixes following the security policy : - cmd/go: arbitrary code execution during build on darwin On Darwin, building a Go module

[go-nuts] question about TestPageAllocAlloc, AllFree1

2024-05-07 Thread Leah Stapleton
I have a question about scavenging arising one of the runtime tests in runtime/mpagealloc.go. The test in question is the " AllFree1" test case in TestPageAllocAlloc. According to my understanding, in the runtime, there is a distinction between reclaiming memory and scavenging memory.

[go-nuts] Re: IOPS profiling

2024-05-06 Thread Jason E. Aten
try https://github.com/felixge/fgprof On Monday, May 6, 2024 at 9:42:22 PM UTC+1 Ethan Reesor wrote: > I'm seeing some pretty strong indications that my application (which is > running on AWS EC2) is bottlenecked by IOPS (I/O operations per second). > > Is there anything like `go test

Re: [go-nuts] variable set in a loop but unused not failing compilation

2024-05-06 Thread Tiago de Bem Natel de Moura
Hi Axel, Thanks for the explanation, it makes sense. Yes, I think it would be a good case for a `vet` warning. On Monday 6 May 2024 at 15:35:02 UTC+1 Axel Wagner wrote: > Hi, > > I'll note that this has nothing, really, to do with the loop, but with the > fact that you are assigning a struct

[go-nuts] IOPS profiling

2024-05-06 Thread Ethan Reesor
I'm seeing some pretty strong indications that my application (which is running on AWS EC2) is bottlenecked by IOPS (I/O operations per second). Is there anything like `go test -profile=...` and `go tool pprof ...` for IOPS? We're looking at optimizing the database we're using, but I'd much

Re: [go-nuts] just started using modules, what have i missed? (continuation..)

2024-05-06 Thread Ian Lance Taylor
On Mon, May 6, 2024 at 9:40 AM 'simon place' via golang-nuts wrote: > > OK, i had thought, (without understanding why), you can't/don't install > non-main packages, as the error message says. ( as mentioned in previous post) > > simon@fedora:~$ go install github.com/vulkan-go/vulkan@latest >

[go-nuts] just started using modules, what have i missed? (continuation..)

2024-05-06 Thread 'simon place' via golang-nuts
OK, i had thought, (without understanding why), you can't/don't install non-main packages, as the error message says. ( as mentioned in previous post) *simon@fedora:~$ go install github.com/vulkan-go/vulkan@latest* *package github.com/vulkan-go/vulkan is not a main package* but it works

Re: [go-nuts] variable set in a loop but unused not failing compilation

2024-05-06 Thread 'Axel Wagner' via golang-nuts
Hi, I'll note that this has nothing, really, to do with the loop, but with the fact that you are assigning a struct field. For a simpler example, compare this: https://go.dev/play/p/MmR-AhOUQH3 with this: https://go.dev/play/p/Y1uoI8thYuV If you only write to the entire variable, the compiler

[go-nuts] variable set in a loop but unused not failing compilation

2024-05-06 Thread Tiago de Bem Natel de Moura
Hello, We had the bug below in production: https://go.dev/play/p/-jewy7e7UcZ Look at the `opt` variable inside `listGithubPullReviews`, it's set multiple times (inside the loop) but never used... it was supposed to be passed as the last argument of `ListReviews()`. Why Go compiler is not

[go-nuts] Re: Upgrading to last version of dependency without upgrading toolchain?

2024-05-06 Thread 'TheDiveO' via golang-nuts
As I cannot edit the title anymore: it's about upgrading to the last version that can be used without toolchain change, which is not necessarily the "latest" version of a dependency. On Monday, May 6, 2024 at 10:42:17 AM UTC+2 TheDiveO wrote: > FYI, go-mod-upgrade runs the following command

[go-nuts] Re: Upgrading to last version of dependency without upgrading toolchain?

2024-05-06 Thread 'TheDiveO' via golang-nuts
FYI, go-mod-upgrade runs the following command under its hood: go list -u -mod=readonly -f '{{if (and (not (or .Main .Indirect)) .Update)}}{{.Path}}: {{.Version}} -> {{.Update.Version}}{{end}}' -m all On Monday, May 6, 2024 at 10:36:08 AM UTC+2 TheDiveO wrote: > Up front, I have to admit that

[go-nuts] Upgrading to last version of dependency without upgrading toolchain?

2024-05-06 Thread 'TheDiveO' via golang-nuts
Up front, I have to admit that I'm struggling with the newly introduced download-your-go-toolchain-on-the-fly when it comes to: 1. having reproducible builds in a CI/CD pipeline without getting downloaded a different toolchain as installed at the stage start, 2. being a module

Re: [go-nuts] Re: understanding garbage collection logging

2024-05-03 Thread Douglas A. Whitfield
On Fri, 3 May 2024 at 13:05, Alexander Pavlov wrote: > Please note the https://pkg.go.dev/runtime/trace package, its > documentation and following article ( > https://go.dev/blog/execution-traces-2024) provide good examples to start > logging the GC. > Thank you! This is exactly what I needed!

[go-nuts] Re: understanding garbage collection logging

2024-05-03 Thread Alexander Pavlov
Please note the https://pkg.go.dev/runtime/trace package, its documentation and following article (https://go.dev/blog/execution-traces-2024) provide good examples to start logging the GC. -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To

Re: [go-nuts] generics question

2024-05-03 Thread 'Kevin Chowski' via golang-nuts
Sorry for the noise - looks like you meant when passing around objects by this type, not just creating objects. On Friday, May 3, 2024 at 11:02:37 AM UTC-6 Kevin Chowski wrote: > If you are just unhappy about the A and A* while using a literal for C: > note that if you are willing/able to

Re: [go-nuts] generics question

2024-05-03 Thread 'Kevin Chowski' via golang-nuts
If you are just unhappy about the A and A* while using a literal for C: note that if you are willing/able to write a wrapper function instead of using a literal, type inference works well today: func NewC[E any, P Settable[E]](val []E) C[E, P] { return C[E, P]{Val: val} } var c = NewC([]A{1, 2,

Re: [go-nuts] Unused local constants not a compiler error

2024-05-03 Thread Marcello H
In golanglint_ci, there's a 'unused' linter, which will detect unused const vars too. Op vrijdag 3 mei 2024 om 00:18:02 UTC+2 schreef Ian Lance Taylor: > On Thu, May 2, 2024 at 2:48 PM will@gmail.com > wrote: > > > > Was this always the case? Is this a bug? Seems like it should be a >

Re: [go-nuts] Re: just started using modules, what have i missed?.

2024-05-02 Thread 'simon place' via golang-nuts
On Thursday 2 May 2024 at 22:45:55 UTC+1 burak serdar wrote: You can simply clone the github repo. You don't need go get for this. When you're ready, import it and then go mod tidy. ummm, could be the best way, i'll compare with the script, (dummy) route. -- You received this message

Re: [go-nuts] Unused local constants not a compiler error

2024-05-02 Thread Ian Lance Taylor
On Thu, May 2, 2024 at 2:48 PM will@gmail.com wrote: > > Was this always the case? Is this a bug? Seems like it should be a compiler > error, like unused local variables. Yes, it's always been the case. It would probably be painful to change it now. Ian -- You received this message

Re: [go-nuts] understanding garbage collection logging

2024-05-02 Thread Ian Lance Taylor
On Thu, May 2, 2024 at 12:48 PM Doug Whitfield wrote: > > I come from java-land, and am having some trouble figuring out gc logging in > go. I have been asked to contribute to a memory leak issue in Minio, which is > written in Go. The first way to try to rack down a memory leak is heap

[go-nuts] Unused local constants not a compiler error

2024-05-02 Thread will....@gmail.com
Was this always the case? Is this a bug? Seems like it should be a compiler error, like unused local variables. -- 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, send an email to

Re: [go-nuts] Re: just started using modules, what have i missed?.

2024-05-02 Thread burak serdar
You can simply clone the github repo. You don't need go get for this. When you're ready, import it and then go mod tidy. On Thu, May 2, 2024 at 3:39 PM 'simon place' via golang-nuts wrote: > > thanks for the reply, yes a library, that i want to investigate, i don't have > a project until after.

[go-nuts] Re: just started using modules, what have i missed?.

2024-05-02 Thread 'simon place' via golang-nuts
thanks for the reply, yes a library, that i want to investigate, i don't have a project until after. this is whats ive been doing for years, but in 1.22 seems this way of working has stopped being supported. On Thursday 2 May 2024 at 19:31:53 UTC+1 Carla Pfaff wrote: > It's not clear what your

[go-nuts] understanding garbage collection logging

2024-05-02 Thread Doug Whitfield
Hi folks, I come from java-land, and am having some trouble figuring out gc logging in go. I have been asked to contribute to a memory leak issue in Minio, which is written in Go. I found https://www.ardanlabs.com/blog/2019/05/garbage-collection-in-go-part2-gctraces.html but I cannot tell

[go-nuts] Re: just started using modules, what have i missed?.

2024-05-02 Thread 'Carla Pfaff' via golang-nuts
It's not clear what your end goal is. github.com/vulkan-go/vulkan is a library. Do you want to use it as a dependency in one of your projects or not? If you want to use it as a dependency, then yes, "go mod init " your project first before adding a dependency with "go get". On Thursday 2 May

[go-nuts] just started using modules, what have i missed?.

2024-05-02 Thread 'simon place' via golang-nuts
*simon@fedora:~$ go get github.com/vulkan-go/vulkan* *go: go.mod file not found in current directory or any parent directory. 'go get' is no longer supported outside a module. To build and install a command, use 'go install' with a version, like 'go install example.com/cmd@latest' For

[go-nuts] [security] Go 1.22.3 and Go 1.21.10 pre-announcement

2024-05-02 Thread announce
Hello gophers, We plan to issue Go 1.22.3 and Go 1.21.10 during US business hours on Tuesday, May 7. These minor releases include PRIVATE security fixes to the standard library and the toolchain, covering the following CVE: - CVE-2024-24787 Following our security policy, this is the

Re: [go-nuts] loading Directives for ptest and pxtest

2024-05-01 Thread Menno
Hi @Ian, thanks for your answer. These fields are also empty (Reading my message again, I see that I was sloppy and should have specified that). So ideally the fields `load.Package.Internal.Build.[Directives|TestDirective|XTestDirectives]` would be propagated according to the case at hand,

Re: [go-nuts] loading Directives for ptest and pxtest

2024-05-01 Thread Ian Lance Taylor
On Wed, May 1, 2024 at 2:36 PM Menno van Rahden wrote: > > Hello, I'm trying to tweak the Go stdlib test cmd a bit to support certain > directives, but hitting some resistance. > > I'd like to understand why the `load.Package.Internal.Build` instances for > `ptest` and `pxtest` (see: >

[go-nuts] loading Directives for ptest and pxtest

2024-05-01 Thread Menno van Rahden
Hello, I'm trying to tweak the Go stdlib test cmd a bit to support certain directives, but hitting some resistance. I'd like to understand why the `load.Package.Internal.Build` instances for `ptest` and `pxtest` (see:

Re: [go-nuts] tuples! tuples! tuples!

2024-04-30 Thread Andrew Harris
*func main() {for x := range FSeq(strconv.Atoi) { fmt.Println(reflect.TypeOf(x))}}func FSeq[V (... any)](f func(string) V) iter.Seq[V] {return func(yield func(v V) bool)) { yield(f("1234"))}}* *>>> If it wouldn't

Re: [go-nuts] tuples! tuples! tuples!

2024-04-30 Thread roger peppe
On Mon, 29 Apr 2024 at 22:06, Andrew Harris wrote: > 2. On implementation, before considering variadic tuple constraints: There > is tuple machinery already in the type system > , used > for assignments and signatures, but tuples

Re: [go-nuts] Re: command to pre-compile vendor libs

2024-04-30 Thread Harmen
> > It all works fine, just wondering if there's a nicer way to get all > > "compilable" packages stored in /vendor. > > go list ./vendor/... I knew there had to be a simpler way, thanks! -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To

[go-nuts] Re: command to pre-compile vendor libs

2024-04-30 Thread Anthony Martin
Harmen once said: > It all works fine, just wondering if there's a nicer way to get all > "compilable" packages stored in /vendor. go list ./vendor/... Cheers, Anthony -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this

[go-nuts] command to pre-compile vendor libs

2024-04-30 Thread Harmen
Hi, in both my Nix and Docker builds I have a step to build all libraries in /vendor, and then cache that. Works great, saves me multiple minutes for every CI build. Now I would like to improve the command, this is what I currently use: $ go build -v `cat vendor/modules.txt |grep -v '#'|grep -v

Re: [go-nuts] encoding/asn1 I can't Marshal a struct with pointer members

2024-04-29 Thread Jason Phillips
Then that type probably won't work with encoding/asn1. If you have control over the call to asn1.Marshal, you could always create a "data transfer object " to translate between this third-party type and a type that you control that has a

Re: [go-nuts] tuples! tuples! tuples!

2024-04-29 Thread Andrew Harris
*> FWIW this kind of restriction has no precedent in Go. Currently any type may be unnamed. This restriction seems arbitrary and irregular to me. * It seems unpopular. *> Isn't this illegal according to your TupleType syntax above? * Further evidence of a wrong idea :) *>> [T (any, any)]

Re: [go-nuts] encoding/asn1 I can't Marshal a struct with pointer members

2024-04-29 Thread J Liu
Thank you very much for your answer, but I cannot modify the definition of the field because this is the structure of the third-party library. On Monday, April 29, 2024 at 1:01:18 AM UTC+8 Def Ceb wrote: > Most marshal/unmarshal functions are unwilling to marshal/unmarshal > structs with

Re: [go-nuts] tuples! tuples! tuples!

2024-04-29 Thread roger peppe
On Sun, 28 Apr 2024 at 12:10, Andrew Harris wrote: > Bouncing out from some recent discussions on the github issue tracker, it > seems like there's some interest in tuples in Go. I thought the discussion > in #66651 led to some interesting ideas, but it's also beginning to drift. > Maybe this is

Re: [go-nuts] tuples! tuples! tuples!

2024-04-29 Thread Andrew Harris
Brian: 1: There would be no access to implicitly typed tuple elements. Both implicit and named tuple values would expand with `...`, for example in an assignment like `x, y := (0, 0)...`. (FWIW, #64457 suggested decimal names for tuple elements `.0`, `.1` etc.) 2: #64457 and #66651 revealed

Re: [go-nuts] tuples! tuples! tuples!

2024-04-28 Thread roger peppe
I agree with Ian that the named field syntax is too close to structs. For me, tuples start to make sense in Go mainly because they map directly to and from the tuple-like values we already pass to and from functions, and specifically in the context of a variadic type parameter language feature

Re: [go-nuts] encoding/asn1 I can't Marshal a struct with pointer members

2024-04-28 Thread Def Ceb
Most marshal/unmarshal functions are unwilling to marshal/unmarshal structs with pointer fields. Changing them to direct values fixes this. Example: https://go.dev/play/p/ykmpBm0bXqn I do not think there is any other simple alternative. J Liu: I understand this problem. My real program uses

Re: [go-nuts] tuples! tuples! tuples!

2024-04-28 Thread Ian Lance Taylor
On Sun, Apr 28, 2024 at 4:10 AM Andrew Harris wrote: > > 1. Tuple types > Outside of generics, tuple type syntax requires named fields. > > TupleType = "(" { IdentifierList Type [ ", " ] } ")" . > > // e.g.: > type Point (X, Y int) > > More irregularly, the TupleType syntax is used exclusively to

Re: [go-nuts] encoding/asn1 I can't Marshal a struct with pointer members

2024-04-28 Thread J Liu
I understand this problem. My real program uses export correctly, but the problem I have is not export, asn1: structure error: unknown Go type: *pkg.Girl On Sunday, April 28, 2024 at 9:27:42 AM UTC+8 Jan Mercl wrote: > > > On Sun, Apr 28, 2024, 03:03 J Liu <88592...@gmail.com> wrote: > >> My

[go-nuts] Re: tuples! tuples! tuples!

2024-04-28 Thread 'Brian Candler' via golang-nuts
A few questions (I'm ignoring generics for now, and have not cross-referenced the other proposals). 1. Is it possible to access the n'th element of an implicitly typed tuple? More generally, how do you unpack such a tuple - other than by assigning to a compatible named tuple type? 2. How does

[go-nuts] tuples! tuples! tuples!

2024-04-28 Thread Andrew Harris
Bouncing out from some recent discussions on the github issue tracker, it seems like there's some interest in tuples in Go. I thought the discussion in #66651 led to some interesting ideas, but it's also beginning to drift. Maybe this is a better place to brain-dump some ideas. (This could be a

Re: [go-nuts] Re: all.bash fails on Ubuntu 24.04?

2024-04-28 Thread Ulrich Kunitz
As mentioned in #67088 TestAmbientCaps is skipped because the execve call returns operation not permitted (EPERM). It is not successful as I wrote. Am Sa., 27. Apr. 2024 um 22:58 Uhr schrieb Uli Kunitz : > I agree. Ubuntu 22.04 has gdb version 12.1, Ubuntu 24.04 has 15.0.50. > > The second bug

Re: [go-nuts] encoding/asn1 I can't Marshal a struct with pointer members

2024-04-27 Thread Jan Mercl
On Sun, Apr 28, 2024, 03:03 J Liu <8859210...@gmail.com> wrote: > My program is like this: > > type Girl struct { > Name string > Age int > } > > type Person struct { > girl *Girl > job string > } > > > What should I do to Marshal 'Person'? > I think you need to export

[go-nuts] encoding/asn1 I can't Marshal a struct with pointer members

2024-04-27 Thread J Liu
My program is like this: type Girl struct { Name string Age int } type Person struct { girl *Girl job string } What should I do to Marshal 'Person'? -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from

[go-nuts] Re: all.bash fails on Ubuntu 24.04?

2024-04-27 Thread Uli Kunitz
I agree. Ubuntu 22.04 has gdb version 12.1, Ubuntu 24.04 has 15.0.50. The second bug may be a change by kernel 6.8 in the handling of ambient capabilities if the user namespace is changed. The test without changing the user namespace is successful. I have created two issues for the two

Re: [go-nuts] Congrats to the Go team

2024-04-27 Thread Robert Engels
Yes. It is this https://github.com/robaho/fixed/blob/5493e8737df761ffcf6be9441b4b8ae41fcf5da4/fixed_bench_test.go#L10On Apr 27, 2024, at 10:31 AM, Steven Hartland wrote:Do you have the test code for that specific test?That would allow others to have a look at it and also confirm if the test is

Re: [go-nuts] Congrats to the Go team

2024-04-27 Thread Steven Hartland
Do you have the test code for that specific test? That would allow others to have a look at it and also confirm if the test is somehow optimising the function call away. On Sat, 27 Apr 2024 at 05:12, robert engels wrote: > Apologies. The assembly files were reversed. But the timings remain the

Re: [go-nuts] Congrats to the Go team

2024-04-26 Thread Robert Engels
Why would it be optimized away in 1.12 and not optimized away in 1.21?I could have made a mistake in my recording so I’ll test it again tomorrow. On Apr 26, 2024, at 10:03 PM, 'Keith Randall' via golang-nuts wrote:Isn't that assembly exactly the opposite? The code that is passing in registers

Re: [go-nuts] time.ParseDuration does not accept scientific notation

2024-04-26 Thread Scott Pakin
On Friday, April 26, 2024 at 6:08:02 PM UTC-6 Ian Lance Taylor wrote: The first step would be to open a proposal for this change. See https://github.com/golang/proposal#readme. Thanks. Done: proposal: time: allow scientific notation in ParseDuration

[go-nuts] Re: all.bash fails on Ubuntu 24.04?

2024-04-26 Thread 'Keith Randall' via golang-nuts
The first issue there could very well be an incompatibility with the gdb version. On Thursday, April 25, 2024 at 11:02:00 PM UTC-7 Uli Kunitz wrote: > Hi, > > I have installed Ubuntu 24.04 yesterday and there are two failures running > all.bash compiling go from source. I want to check whether

Re: [go-nuts] time.ParseDuration does not accept scientific notation

2024-04-26 Thread Ian Lance Taylor
On Fri, Apr 26, 2024 at 3:39 PM Scott Pakin wrote: > > While parsing output from some third-party program, I discovered that > time.ParseDuration does not accept inputs expressed in scientific notation > even though strconv.ParseFloat does accept such inputs. Here’s an playground > example

[go-nuts] time.ParseDuration does not accept scientific notation

2024-04-26 Thread Scott Pakin
While parsing output from some third-party program, I discovered that time.ParseDuration does not accept inputs expressed in scientific notation even though strconv.ParseFloat does accept such inputs. Here’s an

[go-nuts] Re: Reproducible builds with CGO

2024-04-26 Thread Zxilly Chou
golang will embed the path of the source file into the binary, also the .gopclntab will contains the path. try use -trimpath and see if there's any change. 在2024年4月27日星期六 UTC+8 01:28:05 写道: > Hi All, > > *Does anybody have experience in how the use of CGO and dynamic linking > may affect the

[go-nuts] Reproducible builds with CGO

2024-04-26 Thread Vivi A
Hi All, *Does anybody have experience in how the use of CGO and dynamic linking may affect the reproducibility of a Go project?* *Context* I am trying to reproduce a Linux amd64 binary release using the same source commit, os & dist, Go, C compiler, and linker version. It reproduces locally

Re: [go-nuts] net/http Http Server - fail with Proxy Protocol header (v1/v2)

2024-04-26 Thread Eli Lindsey
The first few bytes on a new TLS connection will be the record layer bytes denoting a handshake and the TLS version field, so 0x160301 or 0x160303. ASCII-based proxy protocol v1 will start out 0x5052 etc, and binary-based proxy protocol v2 has its own initial 12 byte signature of 0x0D0A0D0A

Re: [go-nuts] Congrats to the Go team

2024-04-26 Thread Robert Engels
I agree but in this case it is very consistent. Even if that were the case, wouldn’t that mean that 1.12 had better optimization in this case?I will dig in today and report back with the generated code. On Apr 26, 2024, at 12:17 AM, 'Keith Randall' via golang-nuts wrote:> There is a pretty

[go-nuts] Re: net/http Http Server - fail with Proxy Protocol header (v1/v2)

2024-04-26 Thread 'Brian Candler' via golang-nuts
Really I was unsure whether you can guarantee that the first few bytes of a TLS "client hello" can never happen to be the ASCII characters P R O X Y As a binary protocol I think it's unlikely to occur, but I've not attempted to prove it. On Friday 26 April 2024 at 02:30:51 UTC+1 Eli

[go-nuts] all.bash fails on Ubuntu 24.04?

2024-04-26 Thread Uli Kunitz
Hi, I have installed Ubuntu 24.04 yesterday and there are two failures running all.bash compiling go from source. I want to check whether others experienced the same before creating one or two golang issues. git describe --tags returns go1.22.2. Here are the relevant pieces of the ouput of

Re: [go-nuts] Congrats to the Go team

2024-04-25 Thread 'Keith Randall' via golang-nuts
> There is a pretty significant degradation in AddFixed() which may be concerning to the Go team What is the benchmark for this? I am usually suspicious of sub-nanosecond benchmark times. Generally that indicates that the benchmark completely optimized away and all you are measuring is an

[go-nuts] Re: net/http Http Server - fail with Proxy Protocol header (v1/v2)

2024-04-25 Thread Eli
> And whilst HTTP is a text protocol (and can distingush between PROXY and GET/POST/PUT etc), what about TLS? Proxy protocol is sent as the first bytes on wire after TCP is established, not carried via HTTP headers, so it is easily distinguishable from TLS. I agree with all other points, but

Re: [go-nuts] Congrats to the Go team

2024-04-25 Thread 'Robert Engels' via golang-nuts
Thanks. I noticed those but didn’t look into how to address. Appreciate it. I will rerun. > On Apr 25, 2024, at 12:23 PM, Steven Hartland > wrote: > > Thanks for these, not sure if you noticed the notes from each run e.g. need > >= 4 samples to detect a difference at alpha level 0.05. > >

Re: [go-nuts] Congrats to the Go team

2024-04-25 Thread Steven Hartland
Thanks for these, not sure if you noticed the notes from each run e.g. need >= 4 samples to detect a difference at alpha level 0.05. Basically run the benchmark with a -count=6 or more and then run the tool, and you get a the comparison values which are typically the interesting bit On Thu, 25

Re: [go-nuts] xml to json, parsing xml

2024-04-25 Thread Peter Galbavy
I could really have used the go-xmlstruct a year ago :-) But, if I need to fill in more blanks I will try it! On Thursday 25 April 2024 at 02:24:45 UTC+1 twp...@gmail.com wrote: > You can parse XML and JSON quickly with these tools: > > https://github.com/twpayne/go-xmlstruct >

Re: [go-nuts] xml to json, parsing xml

2024-04-24 Thread twp...@gmail.com
You can parse XML and JSON quickly with these tools: https://github.com/twpayne/go-xmlstruct https://github.com/twpayne/go-jsonstruct They generate Go code that parses all the example XML and JSON files that you throw at them. Regards, Tom On Tuesday, April 23, 2024 at 9:17:33 PM UTC+2 Don

[go-nuts] Re: Offline version of A Tour of Go

2024-04-24 Thread Tony M
thanks this was helpful. Is there a good rule of thumb when updating old "go get" instructions. e.g. Go Tour (googlesource.com)

Re: [go-nuts] Congrats to the Go team

2024-04-24 Thread robert engels
And for the 1.12 vs 1.22: │ /Users/robertengels/go1.12.17.txt │ /Users/robertengels/go1.22.2.txt│ │ sec/op │sec/op vs base │ AddFixed-8 0.5900n ± ∞ ¹ 0.7931n ± ∞ ¹~

Re: [go-nuts] Congrats to the Go team

2024-04-24 Thread 'Robert Engels' via golang-nuts
│ /Users/robertengels/go1.21.5.txt │ /Users/robertengels/go1.22.2.txt│ │

Re: [go-nuts] Congrats to the Go team

2024-04-24 Thread Steven Hartland
What’s it look like when your run it through https://pkg.go.dev/golang.org/x/perf/cmd/benchstat which will provide a nice side by side comparison? On Wed, 24 Apr 2024 at 19:26, 'Robert Engels' via golang-nuts < golang-nuts@googlegroups.com> wrote: > I have a fairly stable project

Re: [go-nuts] Congrats to the Go team

2024-04-24 Thread robert engels
Rough guess, it seems about the same. 1.22.2: BenchmarkAddFixed-8 10 0.7931 ns/op 0 B/op 0 allocs/op

[go-nuts] Re: Congrats to the Go team

2024-04-24 Thread Stephen Illingworth
How does it perform with v1.22.0? I found a small but measurable drop in throughput in one of my projects when compiled with 1.22.0. Issue raised here: https://github.com/golang/go/issues/65647#issuecomment-1944830588 I have a feeling it's an issue with my older development hardware. But it's

[go-nuts] Congrats to the Go team

2024-04-24 Thread 'Robert Engels' via golang-nuts
I have a fairly stable project github.com/robaho/fixed which is almost 100% cpu bound. It doesn’t change so it makes a great way to compare the performance of different Go versions using the same hardware. I took the time to re-run the tests today. Using

Re: [go-nuts] go build v go build .

2024-04-24 Thread Henrique Gogó
On Wed, Apr 24, 2024 at 06:24:33PM +0100, Steve Mynott wrote: > Is there any difference between "go build" and "go build ."? The last param of "go build" is the package to build. If you don't specify anything, it builds the package in the current directory. In you second case, it builds the

[go-nuts] go build v go build .

2024-04-24 Thread Steve Mynott
Is there any difference between "go build" and "go build ."? -- Steve Mynott rsa3072/629FBB91565E591955B5876A79CEFAA4450EBD50 -- 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] Where is my type?

2024-04-24 Thread cpu...@gmail.com
Your answer has put me on the right track. Here's the long version: https://stackoverflow.com/questions/48790663/why-value-stored-in-an-interface-is-not-addressable-in-golang On Wednesday, April 24, 2024 at 6:55:53 PM UTC+2 cpu...@gmail.com wrote: > > In the first case, the interface contains

Re: [go-nuts] Where is my type?

2024-04-24 Thread cpu...@gmail.com
> In the first case, the interface contains a value of type S, which is not writable. The value contained in the interface is not addressable. Thank you for the quick feedback. Why is that? Memory for val has been allocated and val is passed by value (hence copied). Why is that copy not be

[go-nuts] Re: Where is my type?

2024-04-24 Thread cpu...@gmail.com
It's worth noting that before the Unmarshal v is {}(main.S) and afterwards {}(map[string]interface{}) On Wednesday, April 24, 2024 at 6:46:18 PM UTC+2 cpu...@gmail.com wrote: > Every time I feel I've come to terms with how Go works I round a corner > and hit a wall, even after doing this for

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