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

2024-04-20 Thread Dominik Honnef
Also, Staticcheck catches this: $ curl -Os https://go.dev/play/p/oIKGb_uyLb3.go $ staticcheck oIKGb_uyLb3.go oIKGb_uyLb3.go:9:38: the integer division '1 / 13' results in zero (SA4025) -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To

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

2024-04-20 Thread Kurtis Rader
This has nothing to do with the math.Pow function. Dividing two ints (1/13) is not the same as dividing a float by an int (1.0/13). Replace your two `fmt.Printf()` calls with println(1 / 13) println(1.0 / 13) and observe the difference. The fact that both `math.Pow` arguments are of type

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 > } > ```

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

2024-04-19 Thread DrGo
``` 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 } ``` https://go.dev/play/p/oIKGb_uyLb3 -- You received this message because you are subscribed to the

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 >

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:

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

[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

[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] 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] Why Go opt for using * in signature of function that returns a pointer instead of using &?

2024-03-06 Thread Matheus Fassis Corocher
Thank for your answers, makes a lot of sense. Em quarta-feira, 6 de março de 2024 às 02:24:50 UTC-3, Kurtis Rader escreveu: > Anyone familiar with C/C++ will be familiar with the current convention of > using an asterisk to indicate a pointer to the value. Yes, there is a > reasonable

Re: [go-nuts] Why Go opt for using * in signature of function that returns a pointer instead of using &?

2024-03-05 Thread Kurtis Rader
Anyone familiar with C/C++ will be familiar with the current convention of using an asterisk to indicate a pointer to the value. Yes, there is a reasonable argument for using an ampersand but either syntax is essentially arbitrary; thus a coin flip as to which to use. So we might as well use the C

Re: [go-nuts] Why Go opt for using * in signature of function that returns a pointer instead of using &?

2024-03-05 Thread Ian Lance Taylor
On Tue, Mar 5, 2024, 8:33 PM Matheus Fassis Corocher < matheuscoroc...@gmail.com> wrote: > I was studying about pointers and struct in Golang and one thing that I > don't understand is why using * in return of signature of function instead > of & if the return of function is an address of

[go-nuts] Why Go opt for using * in signature of function that returns a pointer instead of using &?

2024-03-05 Thread Matheus Fassis Corocher
I was studying about pointers and struct in Golang and one thing that I don't understand is why using * in return of signature of function instead of & if the return of function is an address of variable? The correct version that works: func NewVertex(X, Y int) **Vertex* { ... return {X,

[go-nuts] Why there is no net.ListenContext?

2023-12-19 Thread Michał Matczuk
If you take a look at net.Listen implementation func Listen(network, address string) (Listener, error) { var lc ListenConfig return lc.Listen(context.Background(), network, address) } you will notice the new listen API net.ListenConfig. This API is context aware, I think it would be

[go-nuts] Why does my time.Ticker work fine for 6 months then suddenly stop sending ticks?

2023-11-26 Thread Ari Croock
Hi, I hope someone here can shed some light on a problem I'm having. There is a detailed explanation on my stackoverflow question: https://stackoverflow.com/questions/77538297/why-does-my-time-ticker-work-fine-for-6-months-then-suddenly-stop-sending-ticks The summary is I have a very simple

Re: [go-nuts] Why golang garbage-collector not implement Generational and Compact gc?

2023-11-13 Thread Yi Duan
Any updates on ROC for golang? I think our services encountered some scalability issues, similar to https://github.com/golang/go/issues/17969 On Tuesday, May 16, 2017 at 10:06:25 PM UTC+8 Ian Lance Taylor wrote: > On Tue, May 16, 2017 at 2:01 AM, wrote: > > > > Generational and Compact gc have

[go-nuts] Why golang's garbage collector didn't free obj when an finalizer is associate with it?

2023-11-05 Thread Soren Yang
As shown in the following code: cyclic structure with finalizer The s1 & s2 didn't been free, and finalizer didn't run. But when enable the line which have been commented, all run as expected(s1 & s2 been free)。 I have seen the comment in

Re: [go-nuts] Why causes []any trouble in type equations?

2023-10-11 Thread Bakul Shah
On Oct 11, 2023, at 11:09 AM, Torsten Bronger wrote: > > Then, all boils down to the fact that you can’t pass []float64 as an > []any. To be honest, I still don’t fully understand why this is > forbidden, so I just accept that the language does not allow it. I think in the first case []any is

Re: [go-nuts] Why causes []any trouble in type equations?

2023-10-10 Thread Kurtis Rader
This has nothing to do with generics. It is a FAQ regarding the conversion of a container type value. You cannot modify the type of the object in a container in a called context. This has been true before generics was introduced. Ignoring generics what do you think should happen if you call a

Re: [go-nuts] Why causes []any trouble in type equations?

2023-10-10 Thread 'Axel Wagner' via golang-nuts
In the second case, the type argument is inferred to be `[]float64`. The constraint on `T` in `do` is that it has to be `[]any`. `[]float64` is not `[]any`, the two are different types, so instantiation fails. Note that even if you explicitly instantiate `do` to `[]any`, you still could not pass a

[go-nuts] Why causes []any trouble in type equations?

2023-10-10 Thread Torsten Bronger
Hallöchen! The two most recent Go blog articles make we wonder why package main func do[T []E, E any](slice T) { } func main() { var a []float64 do(a) } is valid while package main func do[T []any](slice T) { } func main() {

Re: [go-nuts] Why is pdfcpu v0.5.0 290MiB on proxy.golang.org ?

2023-08-25 Thread 'Axel Wagner' via golang-nuts
Not sure if it's a good idea, but you could put them in a separate Go module and only import that from tests. That way they *should* not get downloaded when the module is only imported as a dependency. I think. OTOH you'd have to use `go:embed` to export them, which means every `go test` has to

Re: [go-nuts] Why is pdfcpu v0.5.0 290MiB on proxy.golang.org ?

2023-08-25 Thread Tamás Gulácsi
You're right, thanks. Do you have any simple solution for this (beside deleting those files)? Putting such files in a git submodule or git-LFS seems appropriate but complex. Axel Wagner a következőt írta (2023. augusztus 25., péntek, 10:08:47 UTC+2): > ISTM that's because they include a lot

Re: [go-nuts] Why is pdfcpu v0.5.0 290MiB on proxy.golang.org ?

2023-08-25 Thread 'Axel Wagner' via golang-nuts
ISTM that's because they include a lot of PDFs for samples and test data in their repository now: https://github.com/pdfcpu/pdfcpu/tree/master/pkg/samples (245 MB) https://github.com/pdfcpu/pdfcpu/tree/master/pkg/testdata (77 MB) This isn't due to the module mirror doing anything weird, it's just

[go-nuts] Why is pdfcpu v0.5.0 290MiB on proxy.golang.org ?

2023-08-25 Thread Tamás Gulácsi
go get github.com/pdfcpu/pdfcpu@v0.5.0 hung, so I've investigated: $ go get -x github.com/pdfcpu/pdfcpu/pkg/api@latest # get http://proxy.golang.org/github.com/@v/list # get http://proxy.golang.org/github.com/pdfcpu/pdfcpu/@v/list # get

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

2023-08-18 Thread TheDiveO
test case? On Friday, August 18, 2023 at 9:18:05 AM UTC+2 Dan Kortschak wrote: > 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 > >

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

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

2023-08-18 Thread Nigel Tao
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= https://github.com/golang/image/blob/2b687b56714d59d061135c735913a64fe2b70778/go.sum#L1 That line was

Re: [go-nuts] Why is reflect.Type defined as an interface, but reflect.Value is defined as a struct?

2023-08-17 Thread Ian Lance Taylor
On Thu, Aug 17, 2023 at 10:02 AM Hu Jian wrote: > > I'm curious why reflect.Type is defined as an interface, but reflect.Value is > defined as a struct? I don't see any other implementation of the reflect.Type > interface. reflect.Value is an ordinary struct. The reflect.Type interface is

[go-nuts] Why is reflect.Type defined as an interface, but reflect.Value is defined as a struct?

2023-08-17 Thread Hu Jian
hi all, I'm curious why reflect.Type is defined as an interface, but reflect.Value is defined as a struct? I don't see any other implementation of the reflect.Type interface. -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from

Re: [go-nuts] why the go install package download from official website of go1.21 is less than go1.20?

2023-08-16 Thread Ian Lance Taylor
I think that for 1.21 the biggest difference is that we aren't including debug info with the binaries in $GOROOT/pkg/tool/$GOOS_$GOARCH. That change was made in https://go.dev/cl/475378. Ian Ian On Wed, Aug 16, 2023 at 12:46 PM Jeremy Cattone wrote: > > Looks like on-going work, finally

Re: [go-nuts] why the go install package download from official website of go1.21 is less than go1.20?

2023-08-16 Thread Jeremy Cattone
Looks like on-going work, finally completed in 1.21? https://github.com/golang/go/issues/27151 On Tuesday, August 15, 2023 at 9:31:41 PM UTC-7 Kurtis Rader wrote: > All of the packages are significantly smaller -- not just those for macOS. > So this isn't due to anything specific to the macOS

Re: [go-nuts] why the go install package download from official website of go1.21 is less than go1.20?

2023-08-15 Thread Kurtis Rader
All of the packages are significantly smaller -- not just those for macOS. So this isn't due to anything specific to the macOS package(s). Looking at the release notes for Go 1.21.0 I don't see an obvious explanation for the reduction. Downloading and extracting those two packages shows the

[go-nuts] why the go install package download from official website of go1.21 is less than go1.20?

2023-08-15 Thread xie cui
go1.20.7.darwin-arm64.tar.gz ArchivemacOSARM6492MB go1.21.0.darwin-arm64.tar.gz ArchivemacOSARM6462MB this size reduce about 30%. why the size reduce a lot? -- You received this message because

Re: [go-nuts] Why does Go (so far) not have support for generators/ iterators for custom types ?

2023-08-06 Thread 'Axel Wagner' via golang-nuts
Small corrections: 1. in the first sentence, add an "early days Go" 2. In the second sentence, "now we do have *generics*", not iterators. On Sun, Aug 6, 2023 at 11:35 AM Axel Wagner wrote: > For one, Go did not have generic types or functions, which really limits > the usefulness (and

Re: [go-nuts] Why does Go (so far) not have support for generators/ iterators for custom types ?

2023-08-06 Thread 'Axel Wagner' via golang-nuts
For one, Go did not have generic types or functions, which really limits the usefulness (and abilities to write) custom iterators in Go. Now we do have iterators, but it turns out there still are a lot of subtle Go-specific issues with how to support custom iterator types, which to be honest are

[go-nuts] Why does Go (so far) not have support for generators/ iterators for custom types ?

2023-08-06 Thread Serge Hulne
Why does Go (so far) not have support for generators/ iterators for custom types ? I wrote this workaround: https://github.com/serge-hulne/go_iter But I was wondering what lead to the idea of leaving iterators out in the early days of the design of Go. What simplification of the language was

Re: [go-nuts] Why is type inference still so rudimentary?

2023-08-04 Thread jimmy frasche
I wish there were more cases where the types could be elided. Always leaving it off would be a bad idea but how much to put in should be at the author's discretion. There are times when it clarifies but more times when it just adds extra steps. I know that the current rules have justifications but

Re: [go-nuts] Why is type inference still so rudimentary?

2023-08-04 Thread Ian Lance Taylor
On Fri, Aug 4, 2023 at 8:08 AM Nate Finch wrote: > > If I have a struct > > type User struct { > Name string > ID int > } > > type Group struct { > Leader User > } > > Why is it that the go tool can't infer what type I'm constructing for the > Leader field here? > > g := Group{ >

[go-nuts] Why is type inference still so rudimentary?

2023-08-04 Thread Nate Finch
If I have a struct type User struct { Name string ID int } type Group struct { Leader User } Why is it that the go tool can't infer what type I'm constructing for the Leader field here? g := Group{ Leader: { Name: "Jamie", ID: 5, }, } Cleary, the

Re: [go-nuts] Why not return after calling http.Error()

2023-07-06 Thread Gurunandan Bhat
Thanks to everyone who reassured me. I considered posting a set of links from the most popular Golang tutorials that do not return after calling http.Error(), but then baulked In any case, thanks once again to all in this thread. Regards On Wed, Jul 5, 2023 at 4:13 AM ben...@gmail.com wrote:

Re: [go-nuts] Why not return after calling http.Error()

2023-07-04 Thread ben...@gmail.com
> Every example of http Handler that I have seen so far looks like this: Yes, that's definitely odd. I just grepped my Go source directory (which includes the Go compiler and stdlib and a bunch of other Go code), and almost all of them have a "return" on the next line. For example: $ rg

Re: [go-nuts] Why not return after calling http.Error()

2023-07-04 Thread Jan Mercl
On Tue, Jul 4, 2023 at 5:38 PM Gurunandan Bhat wrote: > Every example of http Handler that I have seen so far looks like this: > > func handleSomeRequest(w http.ResponseWriter, r *http.Request) { > > // do something that returns an error > if err != nil { > http.Error(w,

[go-nuts] Why not return after calling http.Error()

2023-07-04 Thread Gurunandan Bhat
Every example of http Handler that I have seen so far looks like this: func handleSomeRequest(w http.ResponseWriter, r *http.Request) { // do something that returns an error if err != nil { http.Error(w, "Something bad happened", http.SomeAppropriateStatus) } // do other

Re: [go-nuts] Why is reflect.CanAddr() returning false in this case ?

2023-06-22 Thread Jan Mercl
On Thu, Jun 22, 2023 at 12:16 PM christoph...@gmail.com wrote: > > I'm trying to get the uintptr address of a value p for which I have the > reflect.Value so that I can compare it with the value obtained with > v.Pointer() when p is a pointer. > > Here is a simple recursive pointer example code

[go-nuts] Why is reflect.CanAddr() returning false in this case ?

2023-06-22 Thread christoph...@gmail.com
I'm trying to get the uintptr address of a value p for which I have the reflect.Value so that I can compare it with the value obtained with v.Pointer() when p is a pointer. Here is a simple recursive pointer example code showing what happens: https://go.dev/play/p/pST8DierbXS It is a pointer

[go-nuts] Why is the reason that the flame graph in go pprof rotated 180 degrees?

2023-06-12 Thread fliter
Why is the reason that the flame graph in go pprof rotated 180 degrees? The reason I can think of is that it seems that this conforms to the func calling order from top to bottom. Thanks for anyone's discussion and replies -- You received this message because you are subscribed to the Google

Re: [go-nuts] Why does sudog g field hold unsafe.Pointer?

2023-06-07 Thread Ian Lance Taylor
On Wed, Jun 7, 2023 at 5:13 AM 'Mikhail Gritsenko' via golang-nuts wrote: > > Why does sudog struct for elem field for the second node in sendq of a chan > hold unsafe.Pointer BUT the first node of the sendq holds actual value? Is it > somehow related with sendDirect or this is just an address

[go-nuts] Why does os.RemoveAll ignore ErrNotExists?

2023-04-24 Thread xiaq
Hi, The os.RemoveAll function does not return an error when the path doesn't exist. Given that this is documented explicitly and implemented using an explicit check

Re: [go-nuts] Why is there no pure StableSort in golang.org/x/exp/slices?

2023-04-23 Thread Uli Kunitz
I have written the code now and run a benchmark. In the benchmark function slices.Sort is 9% faster than slices.SortFunc, which is ca. 9% faster than slices.SortStableFunc for my benchmark. I don't need stable sort, but assumed that merge sorting would benefit more from presorted runs. On

Re: [go-nuts] Why is there no pure StableSort in golang.org/x/exp/slices?

2023-04-23 Thread 'Axel Wagner' via golang-nuts
It has not been added because it is pointless. Stable sorting is generally slower than regular sorting, as it puts extra constraints on the output and keeping to those makes things slower. And for a total order, *every* sorting algorithm produces a stable sort, as stability only matters if you

[go-nuts] Why is there no pure StableSort in golang.org/x/exp/slices?

2023-04-23 Thread Uli Kunitz
I have a use case where I have to sort int32 slices repeatedly that are already partially sorted. (Imagine a tree of smaller non-overlapping segments of the same slice, where sorting starts at the bottom and moves to the top and the results of the individual sorts are required for the

Re: [go-nuts] why golang not provide likely/unlikely syntax?

2023-03-20 Thread cheng dong
pgo is great tool for optmize branch prediction, hope branch prediction feature merge into pgo as soon as possible On Tuesday, March 21, 2023 at 5:49:34 AM UTC+8 Ian Lance Taylor wrote: > On Mon, Mar 20, 2023 at 9:17 AM cheng dong wrote: > > > > i see golang source ssa guess

Re: [go-nuts] why golang not provide likely/unlikely syntax?

2023-03-20 Thread Ian Lance Taylor
On Mon, Mar 20, 2023 at 9:17 AM cheng dong wrote: > > i see golang source ssa guess BranchLikely/BranchUnLikely, however we could > not tell golang whether if is likely or unlikely. and looks the guess logic > might be far away from real condition We don't want to complicate the language.

[go-nuts] why golang not provide likely/unlikely syntax?

2023-03-20 Thread cheng dong
i see golang source ssa guess BranchLikely/BranchUnLikely, however we could not tell golang whether if is likely or unlikely. and looks the guess logic might be far away from real condition -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To

Re: [go-nuts] Why the extra call to `seed` in this situation?

2023-03-14 Thread Kwaku Biney
Yeah this actually makes sense ``` On Wednesday, March 15, 2023 at 12:11:11 AM UTC Ian Lance Taylor wrote: > On Tue, Mar 14, 2023 at 3:47 PM Kwaku Biney wrote: > > > > i was digging in the rand package and came across NewSource(seed) in the > randpackage which creates a new source in case you

Re: [go-nuts] Why the extra call to `seed` in this situation?

2023-03-14 Thread Ian Lance Taylor
On Tue, Mar 14, 2023 at 3:47 PM Kwaku Biney wrote: > > i was digging in the rand package and came across NewSource(seed) in the > randpackage which creates a new source in case you don't want the global > source set by the package. It returns a Source interface. For some reason, > there's a

[go-nuts] Why the extra call to `seed` in this situation?

2023-03-14 Thread Kwaku Biney
i was digging in the rand package and came across NewSource(seed) in the randpackage which creates a new source in case you don't want the global source set by the package. It returns a Source interface. For some reason, there's a seed method on the Source as well for which Rand implements,

Re: [go-nuts] Why would Go not be able put floats in registers without loss of precision?

2023-03-02 Thread 'Grant Seltzer Richman' via golang-nuts
On Thu, Mar 2, 2023 at 12:07 PM Ian Lance Taylor wrote: > > On Thu, Mar 2, 2023 at 8:43 AM 'Grant Seltzer Richman' via golang-nuts > wrote: > > > > So you're saying this should never happen on arm64? That would make sense > > but i'm having trouble finding the float64 values in registers via

Re: [go-nuts] Why would Go not be able put floats in registers without loss of precision?

2023-03-02 Thread Ian Lance Taylor
On Thu, Mar 2, 2023 at 8:43 AM 'Grant Seltzer Richman' via golang-nuts wrote: > > So you're saying this should never happen on arm64? That would make sense but > i'm having trouble finding the float64 values in registers via bpf. Perhaps > my issue lies in how i'm reading the raw bytes and my

Re: [go-nuts] Why would Go not be able put floats in registers without loss of precision?

2023-03-02 Thread 'Grant Seltzer Richman' via golang-nuts
Hi Ian, So you're saying this should never happen on arm64? That would make sense but i'm having trouble finding the float64 values in registers via bpf. Perhaps my issue lies in how i'm reading the raw bytes and my understanding of ARM. Hard to give an example without just sending a whole

Re: [go-nuts] Why would Go not be able put floats in registers without loss of precision?

2023-03-02 Thread Ian Lance Taylor
On Thu, Mar 2, 2023 at 8:22 AM 'Grant Seltzer Richman' via golang-nuts wrote: > > I'm tracing go functions with uprobes/bpf and printing the contents of > registers/stacks. So I can see the content of registers and stack at the > entry of specified go functions. > > I'm looking at a function

[go-nuts] Why would Go not be able put floats in registers without loss of precision?

2023-03-02 Thread 'Grant Seltzer Richman' via golang-nuts
Hi everyone! I'm tracing go functions with uprobes/bpf and printing the contents of registers/stacks. So I can see the content of registers and stack at the entry of specified go functions. I'm looking at a function with floats as parameters, and what I notice is that sometimes Go puts these

Re: [go-nuts] Why is runtime.Gosched needed in this single-threaded, no-goroutines cgo program?

2023-02-22 Thread 'Marko Bencun' via golang-nuts
That's good to know, thanks. I did log the current OS thread ID using `pthread_self()` as well as with `pthread_threadid_np()` and the thread ID is constant for all hid_write and hid_read calls. The issue appears anyway, unless the scheduler is invoked. On Wed, 15 Feb 2023 at 23:52, Ian Lance

Re: [go-nuts] Why is runtime.Gosched needed in this single-threaded, no-goroutines cgo program?

2023-02-16 Thread David Finkel
On Wed, Feb 15, 2023 at 4:05 PM Ian Lance Taylor wrote: > On Wed, Feb 15, 2023 at 8:42 AM 'Marko Bencun' via golang-nuts > wrote: > > > > I am running into a a weird error in C code that only materializes > > when calling it from Go using cgo. I hope you could help me understand > > this

Re: [go-nuts] Why is runtime.Gosched needed in this single-threaded, no-goroutines cgo program?

2023-02-15 Thread Ian Lance Taylor
On Wed, Feb 15, 2023 at 2:36 PM Marko Bencun wrote: > > That is a good hint, thanks. However, in the Go code above, there are > no goroutines and everything runs in one thread as far as I can tell, > but the issue appears anyway. There are always goroutines, even if your program doesn't start

Re: [go-nuts] Why is runtime.Gosched needed in this single-threaded, no-goroutines cgo program?

2023-02-15 Thread 'Marko Bencun' via golang-nuts
That is a good hint, thanks. However, in the Go code above, there are no goroutines and everything runs in one thread as far as I can tell, but the issue appears anyway. On Wed, 15 Feb 2023 at 22:05, Ian Lance Taylor wrote: > > On Wed, Feb 15, 2023 at 8:42 AM 'Marko Bencun' via golang-nuts >

Re: [go-nuts] Why is runtime.Gosched needed in this single-threaded, no-goroutines cgo program?

2023-02-15 Thread Ian Lance Taylor
On Wed, Feb 15, 2023 at 8:42 AM 'Marko Bencun' via golang-nuts wrote: > > I am running into a a weird error in C code that only materializes > when calling it from Go using cgo. I hope you could help me understand > this behaviour and why calling runtime.Gosched() seems to resolve the > issue. I

[go-nuts] Why is runtime.Gosched needed in this single-threaded, no-goroutines cgo program?

2023-02-15 Thread 'Marko Bencun' via golang-nuts
Dear Gophers I am running into a a weird error in C code that only materializes when calling it from Go using cgo. I hope you could help me understand this behaviour and why calling runtime.Gosched() seems to resolve the issue. I worry that this may not be the right fix, so I want to understand

[go-nuts] why no archive distribution for darwin 1.20.1?

2023-02-14 Thread Mike Andrews
on https://go.dev/dl/ i only see the packaged version this time: go1.20.1.darwin-amd64.pkg whereas historically there have been targz versions as well, such as go1.20.darwin-amd64.tar.gz last time. the targz's are useful to me for controlling and augmenting/customizing the installation.

Re: [go-nuts] Why can't a regexp.Regexp be const

2023-02-13 Thread Pat Farrell
On Monday, February 13, 2023 at 7:08:35 PM UTC-5 David Finkel wrote: So, why can't the regexp be a constant? Only primitive types are allowed to be constant in go Oh, this is what I missed. For cases like this, I tend to create an unexported package variable

Re: [go-nuts] Why can't a regexp.Regexp be const

2023-02-13 Thread David Finkel
On Mon, Feb 13, 2023 at 6:48 PM Pat Farrell wrote: > This won't compile > > var ExtRegex = > regexp.MustCompile("(M|m)(p|P)(3|4))|((F|f)(L|l)(A|a)(C|c))$") > > with a > ./prog.go:10:18: > regexp.MustCompile("((M|m)(p|P)(3|4))|((F|f)(L|l)(A|a)(C|c))$") (value of > type *regexp.Regexp) is not

Re: [go-nuts] Why can't a regexp.Regexp be const

2023-02-13 Thread burak serdar
This compiles just fine, but the regexp compilation fails: https://go.dev/play/p/QvC8CIITUU6 On Mon, Feb 13, 2023 at 4:49 PM Pat Farrell wrote: > This won't compile > > var ExtRegex = > regexp.MustCompile("(M|m)(p|P)(3|4))|((F|f)(L|l)(A|a)(C|c))$") > > with a > ./prog.go:10:18: >

[go-nuts] Why can't a regexp.Regexp be const

2023-02-13 Thread Pat Farrell
This won't compile var ExtRegex = regexp.MustCompile("(M|m)(p|P)(3|4))|((F|f)(L|l)(A|a)(C|c))$") with a ./prog.go:10:18: regexp.MustCompile("((M|m)(p|P)(3|4))|((F|f)(L|l)(A|a)(C|c))$") (value of type *regexp.Regexp) is not constant while const pat =

[go-nuts] why strings.ToLower change the "Ⅱ" to "ii" ?

2023-02-10 Thread 张free
why strings.ToLower change the "Ⅱ" to "ii" ? -- 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 golang-nuts+unsubscr...@googlegroups.com. To view this discussion on

[go-nuts] Why do x509.CertificateRequest ExtraExtensions become attributes?

2023-02-06 Thread Mauro Monteiro
Hello all I am using go crypto libs to create x509 certificate requests (CSR) and certificates. I noticed that CSR template extra extensions become CSR template attributes in case I need to marshal / unmarshal csr templates. For instance, below is a simple code that shows this behaviour:

[go-nuts] Why there are eight bytes pad in the stack frame of main function?

2022-12-19 Thread tarorual
package main func main() { var x int32 = 1 nop(x) } //go:noinline func nop(x int32) {} *Go version: go1.16.15 windows/amd64* I wrote above code and compiled it into assembly with `go1.16.15 tool compile -S -N -l main.go` for truly understanding Go functions call. The following is the

Re: [go-nuts] Why not sync.Mutex is designed as an interface

2022-12-16 Thread 'Yuchen Xie' via golang-nuts
That makes sense. Thanks for replying. regards On Wednesday, November 9, 2022 at 1:11:35 AM UTC+8 Ian Lance Taylor wrote: > On Tue, Nov 8, 2022 at 7:55 AM Xie Yuchen wrote: > > > > I checked with the issue about how to refer no-copy and the check of > cmd/vet. After checking, I'm curious that

[go-nuts] Why this simple sorting code doesn't work?

2022-12-06 Thread hey...@gmail.com
Hi, I have this very simple sorting code: s := make([]int, 0, 100) for i := 1; i <= 20; i++ { s = append(s, i) } sort.Slice(s, func(i, j int) bool { return i > j }) log.Print(s) I expect it to print numbers in reverse order, since items with larger index numbers should be at the front.

[go-nuts] Why variable escapes?

2022-12-01 Thread Stepan Chelyshev
Why does x3 escape? Is it even correct considering s3 and x3 gets destroyed in the same moment (when function main ends)? Why x1 and x2 do not escape? *Code:* package main func main() { // 1 case, doesn't escape, struct field is pointer type S1 struct { val *int }

Re: [go-nuts] Why not sync.Mutex is designed as an interface

2022-11-08 Thread Ian Lance Taylor
On Tue, Nov 8, 2022 at 7:55 AM Xie Yuchen wrote: > > I checked with the issue about how to refer no-copy and the check of cmd/vet. > After checking, I'm curious that why not define mutex as an interface, as > interface always copy like a reference, which means users don't worry to copy > by

[go-nuts] Why not sync.Mutex is designed as an interface

2022-11-08 Thread Xie Yuchen
I checked with the issue about how to refer no-copy and the check of cmd/vet. After checking, I'm curious that why not define mutex as an interface, as interface always copy like a reference, which means users don't worry to copy by value and cause an error. Design by the interface can always

Re: [go-nuts] Why channel latency depends on CPU utilization?

2022-10-31 Thread Ian Lance Taylor
On Mon, Oct 31, 2022 at 2:38 PM Sergey Kurenkov wrote: > > > Your sample code above is entering the scheduler > continuously, which is not a typical characteristic of a real program > that has heavy CPU usage. It's possible that what you are seeing is > contention on the scheduler lock. > > Ian,

Re: [go-nuts] Why channel latency depends on CPU utilization?

2022-10-31 Thread Robert Engels
Entering the scheduler continuously will improve performance - it is known as “keeping things hot”. Waking a thread is usually about 6-7 usecs. So if you never “sleep” you get much lower latency. > On Oct 31, 2022, at 4:55 PM, Sergey Kurenkov > wrote: > >  > > Your sample code above is

Re: [go-nuts] Why channel latency depends on CPU utilization?

2022-10-31 Thread Sergey Kurenkov
> Your sample code above is entering the scheduler continuously, which is not a typical characteristic of a real program that has heavy CPU usage. It's possible that what you are seeing is contention on the scheduler lock. Ian, Don't understand your point. The sample code above actually has

Re: [go-nuts] Why channel latency depends on CPU utilization?

2022-10-31 Thread Sergey Kurenkov
> Your sample code above is entering the scheduler continuously, which is not a typical characteristic of a real program that has heavy CPU usage. It's possible that what you are seeing is contention on the scheduler lock. Ian, Don't understand your point. The sample code above actually has

Re: [go-nuts] Why channel latency depends on CPU utilization?

2022-10-31 Thread Robert Engels
github.com/robaho/go-currency-test has some investigation on this > On Oct 31, 2022, at 3:53 PM, Ian Lance Taylor wrote: > > On Mon, Oct 31, 2022 at 1:34 PM Sergey Kurenkov > wrote: >> >> I am trying to understand why higher CPU utilization leads to longer latency >> in reading from

Re: [go-nuts] Why channel latency depends on CPU utilization?

2022-10-31 Thread Ian Lance Taylor
On Mon, Oct 31, 2022 at 1:34 PM Sergey Kurenkov wrote: > > I am trying to understand why higher CPU utilization leads to longer latency > in reading from channels in golang. Could you help me with this question? > > I wrote a test that reads from channels and measure latency between writing >

[go-nuts] Why channel latency depends on CPU utilization?

2022-10-31 Thread Sergey Kurenkov
I am trying to understand why higher CPU utilization leads to longer latency in reading from channels in golang. Could you help me with this question? I wrote a test that reads from channels and measure latency between writing to a channel and reading from the channel. It shows that the

[go-nuts] Why not judge the status of response in getting module?

2022-09-01 Thread xianzhuo wang
Hi, recently I've been trying to learn the module management.I want to get private module from my own repository. The repository only support HTTP request. I use nginx to proxy to the repository, and nginx listens port 443 and 80. When I try to execute "go get myrepo.com/myrepo", it gives me

[go-nuts] Why not judge the status of response in getting module?

2022-09-01 Thread 王先拙
Hi, recently I've been trying to learn the module management.I want to get private module from my own repository. The repository only support HTTP request. I use nginx to proxy to the repository, and nginx listens port 443 and 80. When I try to execute "go get myrepo.com/myrepo", it gives me

Re: [go-nuts] Why declaring multiple variable at once for same type feature exists in Golang?

2022-08-19 Thread SAIFI
On 18 August 2022 7:20:45 am UTC, Yasser Sinjab wrote: >Hi, > >I'm just wondering why this feature is in Golang: such as > >var x, y, z string > >Thanks, >Yasser > Because it's the greatest programming language, ever ! Saifi. -- You received this message because you are subscribed to the

[go-nuts] Why declaring multiple variable at once for same type feature exists in Golang?

2022-08-18 Thread Yasser Sinjab
Hi, I'm just wondering why this feature is in Golang: such as var x, y, z string Thanks, Yasser -- 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] Why traversing Go hashmap so slower then C++ hashmap

2022-06-28 Thread Ian Lance Taylor
On Tue, Jun 28, 2022 at 9:56 PM Yan Li wrote: > > Question: > Go 161.385148ms vs C++ ms:31 > Go 851.517707ms vs C++ ms:104 > My question is why traversing go map Significantly slowly? > Can it be improved? I don't know exactly why there is a speed difference. That said, there are significant

[go-nuts] Why traversing Go hashmap so slower then C++ hashmap

2022-06-28 Thread Yan Li
*System env:* $ lsb_release -a No LSB modules are available. Distributor ID: Ubuntu Description:Ubuntu 18.04.6 LTS Release:18.04 Codename: bionic $ go version go version go1.18.3 linux/amd64 $ g++ -v gcc version 7.5.0 (Ubuntu 7.5.0-3ubuntu1~18.04) *Test traversing Go hashmap:*

  1   2   3   4   5   6   7   8   9   10   >