[go-nuts] is func schedule always run on g0's stack?

2021-03-13 Thread xie cui
https://github.com/golang/go/blob/master/src/runtime/proc.go#L3086 -- 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

[go-nuts] insane idea to eliminate CGO latency

2021-03-13 Thread Jason E. Aten
I was noodling about how to minimize the cost of crossing the CGO barrier from Go code into C code and back. Then I thought, what if I look at this the other way around. Instead of teaching the Go compiler how to better run C code, what if a C compiler (e.g. clang) was taught to generate code

[go-nuts] Re: Does current GC move object now?

2021-03-13 Thread rmfr
Maybe the reason for such a strict rule on using cgo is just to take precautions if our GC moves object in the future? And at that time, the syscall implementation must be rewritten to add some codes to pinning the objects used by each syscall from being moved. Am I correct? On Sunday, March

[go-nuts] Does current GC move object now?

2021-03-13 Thread rmfr
I am watching the implementation of syscall `writev` from [here](https://github.com/golang/sys/blob/bd2e13477e9c63125302cd9da2d61879c6aa1721/unix/zsyscall_linux.go#L1641), and comparing it with the [proposal](https://github.com/golang/proposal/blob/master/design/12416-cgo-pointers.md) of

[go-nuts] Re: How to call a C `writev` styled library api via cgo without allocation and copying of the whole byte slice vector?

2021-03-13 Thread rmfr
I have read this proposal carefully https://github.com/golang/proposal/blob/master/design/12416-cgo-pointers.md#proposal 1. Go code may pass a Go pointer to C provided that the Go memory to which it points does not contain any Go pointers. - The C code must not store any Go

Re: [go-nuts] Unexpected error from os.DirEntry on Win10

2021-03-13 Thread rob
I need file timestamp and size, so I need a full FileInfo. -- rob drrob...@fastmail.com On Sat, Mar 13, 2021, at 6:11 PM, Axel Wagner wrote: > > > On Sat, Mar 13, 2021 at 11:52 PM rob wrote: >> Sorry, I did not intend to open a new thread. >> I don't know how to answer you about the

Re: [go-nuts] Re: Error running gollvm on Ubuntu 20.04

2021-03-13 Thread Khanh TN
Hi, Ian, It does look like importing golang.org/x/sys/unix causes the problem A simple go program like package main import ( "fmt" "golang.org/x/sys/unix" ) func main() { fmt.Println("Hello, World!") fmt.Println(unix.Getpagesize()) } does cause the same error as

Re: [go-nuts] Re: Error running gollvm on Ubuntu 20.04

2021-03-13 Thread Khanh TN
Hi Ian, "gold --version" gives me "GNU gold (GNU Binutils for Ubuntu 2.34) 1.16" "go list -m all" does list the module golang.org/x/sys. Does it help with the case? Thanks for your help. Khanh On Wednesday, March 10, 2021 at 11:14:19 AM UTC+8 Ian Lance Taylor wrote: > I'm not sure. What

Re: [go-nuts] Unexpected error from os.DirEntry on Win10

2021-03-13 Thread 'Axel Wagner' via golang-nuts
On Sat, Mar 13, 2021 at 11:52 PM rob wrote: > Sorry, I did not intend to open a new thread. > > I don't know how to answer you about the actual contents of the directory > of interest. It's my c:\users\rob\Documents directory. > > There are a lot of files there. I'm writing my own version of

Re: [go-nuts] Unexpected error from os.DirEntry on Win10

2021-03-13 Thread rob
Sorry, I did not intend to open a new thread. I don't know how to answer you about the actual contents of the directory of interest.  It's my c:\users\rob\Documents directory. There are a lot of files there.  I'm writing my own version of the dir command, one that will sort and behave

Re: [go-nuts] Re: sort string slice like it contains key,val

2021-03-13 Thread 'Axel Wagner' via golang-nuts
One thing I would add is that you'll likely want to use the *Stable versions of the sort functions, to make sure the order of equivalent elements does not change. Apart from that, the solution posted by Carla above with an added step to remove duplicates seems like the best solution. On Sat, Mar

Re: [go-nuts] Re: sort string slice like it contains key,val

2021-03-13 Thread Vasiliy Tolstov
вс, 14 мар. 2021 г. в 01:10, Brian Candler : > > If I understand rightly, the values in the slice are to be interpreted (key, > value) pairs? In that case, the natural thing to me is to build a map. This > also takes care of "duplicate key, last value wins". You can then sort the > keys and

[go-nuts] Re: sort string slice like it contains key,val

2021-03-13 Thread Brian Candler
If I understand rightly, the values in the slice are to be interpreted (key, value) pairs? In that case, the natural thing to me is to build a map. This also takes care of "duplicate key, last value wins". You can then sort the keys and convert it back: https://play.golang.org/p/dTjmO18T1vQ

Re: [go-nuts] sort string slice like it contains key,val

2021-03-13 Thread Vasiliy Tolstov
вс, 14 мар. 2021 г. в 00:41, Robert Engels : > > That wasn’t specified in the assignment :) =) As always after first stuff i need the second =) > > On Mar 13, 2021, at 2:59 PM, Levieux Michel wrote: > >  > Your need is not only to sort your data elements then..? > Using the previously advised

Re: [go-nuts] sort string slice like it contains key,val

2021-03-13 Thread Vasiliy Tolstov
I think that remove after sort is good for me, thanks сб, 13 мар. 2021 г. в 23:59, Levieux Michel : > > Your need is not only to sort your data elements then..? > Using the previously advised solution you can just range the slice *after* > you sort it, so you can just check for the next element,

Re: [go-nuts] sort string slice like it contains key,val

2021-03-13 Thread Robert Engels
That wasn’t specified in the assignment :) > On Mar 13, 2021, at 2:59 PM, Levieux Michel wrote: > >  > Your need is not only to sort your data elements then..? > Using the previously advised solution you can just range the slice *after* > you sort it, so you can just check for the next

Re: [go-nuts] sort string slice like it contains key,val

2021-03-13 Thread Levieux Michel
Your need is not only to sort your data elements then..? Using the previously advised solution you can just range the slice *after* you sort it, so you can just check for the next element, which I'd say is not *too bad*, what are your performance constraints? Le sam. 13 mars 2021 à 21:33, Vasiliy

Re: [go-nuts] sort string slice like it contains key,val

2021-03-13 Thread Vasiliy Tolstov
Looks fine =) But how to remove duplicates? I'm found this stuff https://github.com/campoy/unique/blob/master/unique.go but as i understand it needs to adapt to my case =) сб, 13 мар. 2021 г. в 16:47, 'Carla Pfaff' via golang-nuts : > > On Saturday, 13 March 2021 at 14:44:05 UTC+1

Re: [go-nuts] No generic, part -2

2021-03-13 Thread 'Axel Wagner' via golang-nuts
On Sat, Mar 13, 2021 at 6:24 PM Space A. wrote: > There is a huge difference between generics and some regular questions > like `Etag` implementation, isn't it? In time, investments, "community > demand", commitments to upper management, etc > Indeed. That doesn't change the fact that Russ has

Re: [go-nuts] No generic, part -2

2021-03-13 Thread Martin Schnabel
hi jan, i mostly share your perspective, but i may be a bit more optimistic. the language as-is can be used to write horrible code already (i know because i did and still sometimes do). i am also sure that many will "abstract prematurely" before they see the light and come to reason (i will

Re: [go-nuts] Auto Make a named return map

2021-03-13 Thread 'Axel Wagner' via golang-nuts
On Sat, Mar 13, 2021 at 6:14 PM Kevin Chadwick wrote: > Nonsense around performance is the reason that c sucks. > Lack of "nonsense around performance" is also the reason why many people use Go instead of, say, Python. I'm once again not sure what your objective is here. No one is trying to

Re: [go-nuts] No generic, part -2

2021-03-13 Thread Space A.
> Here is a recent example I was involved in . He originally said, in no uncertain terms, that `ETag`s will be supported when an `embed.FS` is served over `net/http`. There is a huge difference between generics and some regular

Re: [go-nuts] Auto Make a named return map

2021-03-13 Thread Kevin Chadwick
On Sat, 13 Mar 2021, 17:00 Jan Mercl, <0xj...@gmail.com> wrote: > On Sat, Mar 13, 2021 at 5:52 PM Kevin Chadwick > wrote: > > > Very little resources, unless the map is actually used and not for long. > If you really need to control gos memory use, you need to preallocate > arrays in a long

Re: [go-nuts] Auto Make a named return map

2021-03-13 Thread Jan Mercl
On Sat, Mar 13, 2021 at 5:52 PM Kevin Chadwick wrote: > Very little resources, unless the map is actually used and not for long. If > you really need to control gos memory use, you need to preallocate arrays in > a long standing manner anyway, not for maps though, as you can't delete >

[go-nuts] Re: No generic, part -2

2021-03-13 Thread jake...@gmail.com
This thread seems like it has devolved into a rehashing of the recent Generics, please go away! thread . This seems unfair to the original poster, who asked a simple , respectful, question in good faith, and seems to be

Re: [go-nuts] Auto Make a named return map

2021-03-13 Thread Kevin Chadwick
On Sat, 13 Mar 2021, 15:05 Jan Mercl, <0xj...@gmail.com> wrote: > On Fri, Mar 12, 2021 at 1:24 AM Kevin Chadwick > wrote: > > > Why doesn't go auto init or make an empty map for a named return to > avoid the potential chance of a panic due to operating on a nil return? > > A non-zero value map

Re: [go-nuts] No generic, part -2

2021-03-13 Thread 'Axel Wagner' via golang-nuts
On Sat, Mar 13, 2021 at 4:59 PM Space A. wrote: > You are a smart guy, one of the smartest I have ever talked to. But it > looks like you somehow missed a very obvious thing. The people you > mentioned (and most of the so-called Go team) AFAIK are Google employees. > They work for a company and

Re: [go-nuts] No generic, part -2

2021-03-13 Thread 'Carla Pfaff' via golang-nuts
On Saturday, 13 March 2021 at 15:31:05 UTC+1 Space A. wrote: > There wasn't even a poll or anything. So the question of whether this > topic should be dropped completely (a lot of reasons why) has not been > thought out. > It was already explained that Go development is not driven by polls or

Re: [go-nuts] Re: go get v git clone

2021-03-13 Thread arthurwil...@gmail.com
On Saturday, March 13, 2021 at 8:44:44 AM UTC-6 Jan Mercl wrote: > On Sat, Mar 13, 2021 at 3:35 PM arthurwil...@gmail.com > wrote: > > > I just want to remove one thing go getted, not the entire cache. > > For new features one can fill a proposal. If accepted, a follow-up > with the

Re: [go-nuts] Re: go get v git clone

2021-03-13 Thread arthurwil...@gmail.com
On Saturday, March 13, 2021 at 10:02:50 AM UTC-6 Jan Mercl wrote: > On Sat, Mar 13, 2021 at 4:57 PM arthurwil...@gmail.com > wrote: > > > OK I'll try and figure out how to do that. What is a CL? > > Change List. A patch against the repository that implements a feature, > fixes a bug etc.

Re: [go-nuts] Re: go get v git clone

2021-03-13 Thread Jan Mercl
On Sat, Mar 13, 2021 at 4:57 PM arthurwil...@gmail.com wrote: > OK I'll try and figure out how to do that. What is a CL? Change List. A patch against the repository that implements a feature, fixes a bug etc. -- You received this message because you are subscribed to the Google Groups

Re: [go-nuts] No generic, part -2

2021-03-13 Thread Jan Mercl
On Sat, Mar 13, 2021 at 4:43 PM 'Axel Wagner' via golang-nuts wrote: > > I don't think it is useful to quibble over the definition of "ignore". When I > said it is demonstrably false that arguments have been ignored, I was > assuming what I perceive to be the common definition: "refuse to take

Re: [go-nuts] No generic, part -2

2021-03-13 Thread Space A.
You are a smart guy, one of the smartest I have ever talked to. But it looks like you somehow missed a very obvious thing. The people you mentioned (and most of the so-called Go team) AFAIK are Google employees. They work for a company and they are paid for the work they do. If, as you say, they

Re: [go-nuts] Re: go get v git clone

2021-03-13 Thread arthurwil...@gmail.com
On Saturday, March 13, 2021 at 8:44:44 AM UTC-6 Jan Mercl wrote: > On Sat, Mar 13, 2021 at 3:35 PM arthurwil...@gmail.com > wrote: > > > I just want to remove one thing go getted, not the entire cache. > > For new features one can fill a proposal. If accepted, a follow-up > with the

Re: [go-nuts] No generic, part -2

2021-03-13 Thread 'Axel Wagner' via golang-nuts
I don't think it is useful to quibble over the definition of "ignore". When I said it is demonstrably false that arguments have been ignored, I was assuming what I perceive to be the common definition: "refuse to take notice of or acknowledge; disregard intentionally. fail to consider (something

Re: [go-nuts] No generic, part -2

2021-03-13 Thread Jan Mercl
On Sat, Mar 13, 2021 at 4:18 PM Bruno Albuquerque wrote: > FWIIW, I also agree that "ignore" makes no sense here. You might listen and > think about several opinions/options and conclude that one of them is the > best one. This does not mean you ignored all the others. You do not ignore the

Re: [go-nuts] No generic, part -2

2021-03-13 Thread 'Axel Wagner' via golang-nuts
On Sat, Mar 13, 2021 at 4:19 PM Space A. wrote: > > The discussion of whether or not generics will be added to Go has been > going on for more than a decade. > That's a lie. There has never been a question of "add it or not". It was > always "we will add them" sooner or later. > It is somewhat

Re: [go-nuts] No generic, part -2

2021-03-13 Thread Space A.
> The discussion of whether or not generics will be added to Go has been going on for more than a decade. That's a lie. There has never been a question of "add it or not". It was always "we will add them" sooner or later. сб, 13 мар. 2021 г. в 17:31, 'Axel Wagner' via golang-nuts <

Re: [go-nuts] No generic, part -2

2021-03-13 Thread Bruno Albuquerque
FWIIW, I also agree that "ignore" makes no sense here. You might listen and think about several opinions/options and conclude that one of them is the best one. This does not mean you ignored all the others. On Sat, Mar 13, 2021 at 7:06 AM 'Axel Wagner' via golang-nuts <

Re: [go-nuts] No generic, part -2

2021-03-13 Thread 'Axel Wagner' via golang-nuts
On Sat, Mar 13, 2021 at 4:00 PM Jan Mercl <0xj...@gmail.com> wrote: > On Sat, Mar 13, 2021 at 3:53 PM Axel Wagner > wrote: > > > We have different interpretations of "ignore". To me, "ignore" means "be > unaware of or pretend they don't exist". > > You seem to use it as "disagree about their

Re: [go-nuts] Auto Make a named return map

2021-03-13 Thread Jan Mercl
On Fri, Mar 12, 2021 at 1:24 AM Kevin Chadwick wrote: > Why doesn't go auto init or make an empty map for a named return to avoid the > potential chance of a panic due to operating on a nil return? A non-zero value map value must be allocated. All well-known Go compilers allocate maps in heap.

Re: [go-nuts] No generic, part -2

2021-03-13 Thread Jan Mercl
On Sat, Mar 13, 2021 at 3:53 PM Axel Wagner wrote: > We have different interpretations of "ignore". To me, "ignore" means "be > unaware of or pretend they don't exist". > You seem to use it as "disagree about their validity or the weight they are > given in the decision". That seems

Re: [go-nuts] No generic, part -2

2021-03-13 Thread 'Axel Wagner' via golang-nuts
On Sat, Mar 13, 2021 at 3:42 PM Jan Mercl <0xj...@gmail.com> wrote: > Not false at all. If you have more than one party, differing in > conflicting opinions on a subject and you make a final decision, you > _must_ ignore at least arguments of one of the parties. We have different

Re: [go-nuts] Auto Make a named return map

2021-03-13 Thread 'Axel Wagner' via golang-nuts
On Sat, Mar 13, 2021 at 3:22 PM Kevin Chadwick wrote: > In that case, as far as I understand it, which may be a limited > understanding. I > disagree with this being a useful property. That is your prerogative. I was simply trying to explain why maps work the way they do (and ISTM that if you

Re: [go-nuts] Re: go get v git clone

2021-03-13 Thread Jan Mercl
On Sat, Mar 13, 2021 at 3:35 PM arthurwil...@gmail.com wrote: > I just want to remove one thing go getted, not the entire cache. For new features one can fill a proposal. If accepted, a follow-up with the implementation CL is very nice -- You received this message because you are subscribed

Re: [go-nuts] No generic, part -2

2021-03-13 Thread alex-coder
Hello again. Looks like I have the several problems. :-) First one is my English, it seems my written explanations not properly describe my wishes. Next one is that I have missed the already closed discussion and include my opinion in context where it would be unnecessary. So, of course, of

Re: [go-nuts] No generic, part -2

2021-03-13 Thread Jan Mercl
On Sat, Mar 13, 2021 at 3:31 PM 'Axel Wagner' via golang-nuts wrote: > I want to re-iterate: The discussion of whether or not generics will be added > to Go has been going on for more than a decade. All arguments from all sides > have gotten fair consideration. A decision was reached. > > You

[go-nuts] Re: go get v git clone

2021-03-13 Thread arthurwil...@gmail.com
On Friday, March 12, 2021 at 11:13:44 PM UTC-6 Carla Pfaff wrote: > You use git clone. Go get is for adding a dependency to a project. > > Also how do I delete something I go getted? >> > > ~/go/pkg/mod is just a local cache, nothing you work in. You can clear the > whole module cache with

[go-nuts] How to call a C `writev` styled library api via cgo without allocation and copying of the whole byte slice vector?

2021-03-13 Thread rmfr
Say here is a C api like `ssize_t writev(const struct iovec *iov, int iovcnt)` which the definition of iovec is like below: ``` struct iovec { uint8_t *Base; /* Base address. */ uint64_t Len;/* Length. */ }; ``` For C api which like `ssize_t write(const void *buf, size_t

Re: [go-nuts] No generic, part -2

2021-03-13 Thread 'Axel Wagner' via golang-nuts
I want to re-iterate: The discussion of whether or not generics will be added to Go has been going on for more than a decade. All arguments from all sides have gotten fair consideration. A decision was reached. You might not agree with that decision. But saying that "there are no arguments" or

Re: [go-nuts] No generic, part -2

2021-03-13 Thread Space A.
> There have been many discussions and debates about generics (first as to whether they should be added at all That's simply not true, there have never been raised a discussion of whether they should be added or not. There wasn't even a poll or anything. So the question of whether this topic

Re: [go-nuts] Auto Make a named return map

2021-03-13 Thread Kevin Chadwick
On 3/13/21 1:40 PM, Axel Wagner wrote: > > Compiler complication is not the concern. It would be easy to build any of the > suggested semantics into the language. It is just that none of the suggestions > so far seem clearly better - that is, they all come with their own downsides. > OK, I

Re: [go-nuts] No generic, part -2

2021-03-13 Thread Space A.
HI Martin, as Jan already explained, you're not only writing code, you also reading it. And you have to understand what's written. At the same time you're not just coding in Go, you're using the whole ecosystem including libraries and tools. So the mantra "just don't use if you don't like'' does

Re: [go-nuts] it seems the func NewSparseTreeHelper is not used by any code?

2021-03-13 Thread 'Axel Wagner' via golang-nuts
I agree, it seems unused. Someone probably forgot to delete it when it was replaced by something else. On Sat, Mar 13, 2021 at 3:09 PM xie cui wrote: > > https://github.com/golang/go/blob/master/src/cmd/compile/internal/ssa/sparsetreemap.go#L59 > where is code call NewSparseTreeHelper, the

[go-nuts] it seems the func NewSparseTreeHelper is not used by any code?

2021-03-13 Thread xie cui
https://github.com/golang/go/blob/master/src/cmd/compile/internal/ssa/sparsetreemap.go#L59 where is code call NewSparseTreeHelper, the comment says it is used by gc package, by i can not find it. please help? -- You received this message because you are subscribed to the Google Groups

Re: [go-nuts] sort string slice like it contains key,val

2021-03-13 Thread 'Carla Pfaff' via golang-nuts
On Saturday, 13 March 2021 at 14:44:05 UTC+1 mlevi...@gmail.com wrote: > the sort package from the stdlib, it contains an interface that you can > easily implement for such problematics :) > Like this: https://play.golang.org/p/eoLJ2aVAWkD -- You received this message because you are

Re: [go-nuts] sort string slice like it contains key,val

2021-03-13 Thread Levieux Michel
Hi, You should take a look at the sort package from the stdlib, it contains an interface that you can easily implement for such problematics :) Hope this helps! Le sam. 13 mars 2021 à 14:37, Vasiliy Tolstov a écrit : > Hi! > I'm stuck at sorting stuff like > >

Re: [go-nuts] Auto Make a named return map

2021-03-13 Thread 'Axel Wagner' via golang-nuts
On Sat, Mar 13, 2021 at 2:14 PM Kevin Chadwick wrote: > > > > > I don't think we should change creation; what about having the first > insert > > make the map if it's nil? > > > > It seems that would be fairly transparent. > > > > This wouldn't solve the problem that I saw. It

[go-nuts] sort string slice like it contains key,val

2021-03-13 Thread Vasiliy Tolstov
Hi! I'm stuck at sorting stuff like []string{"xxxkey","xxxval","zzzkey","zzzval","aaakey","aaaval","zzzkey","val"} i need to get after sorting something like []string{"aaakey","aaaval", "xxxkey","xxxval","zzzkey","val"} So i'm sort by "key" and if key is duplicated - last wins. Mostly i

Re: [go-nuts] No generic, part -2

2021-03-13 Thread Levieux Michel
It's not because the arguments didn't appear numerous / convincing enough that they were not taken into account. You are just stating your incapacity to accept that you might be wrong, as anyone can, and that you cannot discuss something (clearly because you don't want to *discuss*, you want

Re: [go-nuts] Auto Make a named return map

2021-03-13 Thread Kevin Chadwick
> > I don't think we should change creation; what about having the first > insert > make the map if it's nil? > > It seems that would be fairly transparent. > This wouldn't solve the problem that I saw. Whilst, an easy personal fix is to make sure coders always make a map

Re: [go-nuts] No generic, part -2

2021-03-13 Thread Jan Mercl
On Sat, Mar 13, 2021 at 1:44 PM Martin Schnabel wrote: > as far as i know there is no reason that anybody has to write code with > generics when they are available. therefor i really don't understand the > negative mails to this list. That nonchalantly ignores that code is way more often read

Re: [go-nuts] No generic, part -2

2021-03-13 Thread Martin Schnabel
(sorry space a, i didn't reply to list) hi alex and space a. as far as i know there is no reason that anybody has to write code with generics when they are available. therefor i really don't understand the negative mails to this list. do you also want others not to use them? how would that

Re: [go-nuts] No generic, part -2

2021-03-13 Thread Space A.
There is no rationale. They decided, and they implemented. No one from Go team ever took the argument against it seriously because "community" demands, blabla. And because Russ Cox with friends written an academic paper so this is now a question of pure science. Write your own and they could

Re: [go-nuts] struct conversion, new fields, and incompatibility

2021-03-13 Thread Brian Candler
Thanks for the clarification, and I agree completely. There are plenty of cases in the Go standard library where there is a public struct for bundling state, and I don't see adding a new member (whether it's private or public) as a breaking change. Nobody's going to attempt to mirror the

Re: [go-nuts] Auto Make a named return map

2021-03-13 Thread 'Axel Wagner' via golang-nuts
On Sat, Mar 13, 2021 at 1:24 AM Matthew Holiday wrote: > I don't think we should change creation; what about having the first > insert make the map if it's nil? > > It seems that would be fairly transparent. > I assume you accidentally hit "Reply" instead of "Reply All". This isn't as simple