Re: [go-nuts] go cycle reference type - what's the practical usage of decls like "type T *T" and similars?

2021-03-15 Thread messi...@gmail.com
Thanks Ian, the state machine case reminds me of a video by Rob Pike: https://www.youtube.com/watch?v=HxaD_trXwRE , put the link here to help others who are interested :-) On Tuesday, March 16, 2021 at 12:58:00 PM UTC+8 Ian Lance Taylor wrote: > On Mon, Mar 15, 2021 at 9:23 PM

Re: [go-nuts] go cycle reference type - what's the practical usage of decls like "type T *T" and similars?

2021-03-15 Thread Ian Lance Taylor
On Mon, Mar 15, 2021 at 9:23 PM messi...@gmail.com wrote: > > In file cycles.src there're many type declarations to demo cycle reference, > some are invalid and some are valid, I can understand why invalid ones are > invalid, but for some of the valid ones, I cannot figure out their usage >

[go-nuts] go cycle reference type - what's the practical usage of decls like "type T *T" and similars?

2021-03-15 Thread messi...@gmail.com
Hi, In file cycles.src there're many type declarations to demo cycle reference, some are invalid and some are valid, I can understand why invalid ones are invalid, but for some of the valid ones, I

Re: [go-nuts] running tests against benchmarks

2021-03-15 Thread Jeremy French
Nice! Thanks. On Mon, Mar 15, 2021 at 10:36 PM Wojciech S. Czarnecki wrote: > Dnia 2021-03-15, o godz. 10:44:50 > Jeremy French napisał(a): > > > So it seems like the logical solution would be to create a test that > runs a > > benchmark and makes sure the benchmark results are within some >

Re: [go-nuts] running tests against benchmarks

2021-03-15 Thread Wojciech S. Czarnecki
Dnia 2021-03-15, o godz. 10:44:50 Jeremy French napisał(a): > So it seems like the logical solution would be to create a test that runs a > benchmark and makes sure the benchmark results are within some acceptable > range. I realize that benchmarks are going to differ from machine to >

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

2021-03-15 Thread Ian Lance Taylor
Yes. -- 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 the web visit

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

2021-03-15 Thread Ian Lance Taylor
On Sat, Mar 13, 2021 at 10:26 PM rmfr wrote: > > 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

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

2021-03-15 Thread Robert Engels
Very well said. > On Mar 15, 2021, at 7:04 PM, Jeremy French wrote: > > I was really trying not to weigh in here, mostly because it's a decision > that has been decided, so there's not a lot of point in continuing the > discussion, and yesterday it seemed like the thread would die, yet...

Re: [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-15 Thread Ian Lance Taylor
On Sat, Mar 13, 2021 at 6:25 AM rmfr wrote: > > 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. */ > }; > ``` >

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

2021-03-15 Thread Khanh TN
Hi Ian, This problem is somewhat resolved for me now. Gollvm works perfectly in my fresh installed Debian. Maybe Go and Gollvm has some conflicts in my previous build or Ubuntu got some problem. Thanks a lot for your help. Khanh On Tuesday, March 16, 2021 at 7:53:34 AM UTC+8 Ian Lance Taylor

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

2021-03-15 Thread Jeremy French
I was really trying not to weigh in here, mostly because it's a decision that has been decided, so there's not a lot of point in continuing the discussion, and yesterday it seemed like the thread would die, yet... it continues. For context, I was against the generics proposal, primarily

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

2021-03-15 Thread Ian Lance Taylor
On Sat, Mar 13, 2021 at 4:51 PM Khanh TN wrote: > > 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!")

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

2021-03-15 Thread 'Colin Arnott' via golang-nuts
Sweet, I will open up the proposal, unless there is mass descent to this idea. I will call out that this WILL make implementing marshaling logic harder, but it seems orthogonal to the desire for a vet check to prevent random code breakage. On Mon, 15 Mar 2021, 23:31 Ian Lance Taylor, wrote: >

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

2021-03-15 Thread Ian Lance Taylor
It may be worth noting that we already have a vet check for composite literals that verifies that if a composite literal is used with a struct defined in a different package, then the fields are explicitly named. This check means that adding fields to a struct will never break composite literals

Re: [go-nuts] insane idea to eliminate CGO latency

2021-03-15 Thread Robert Engels
I think it is more of using a specialized compiler on unmodified C code and expecting it to work. > On Mar 15, 2021, at 3:58 PM, Andy Balholm wrote: > >  > By the way, this existed at one point. Early versions of the Go toolchain > included C compilers (6c, 8c, etc.) designed to work

Re: [go-nuts] Error while executing exec.command

2021-03-15 Thread 'Axel Wagner' via golang-nuts
I would also suggest to just use os.ReadFile , instead of executing `cat`. The latter is pointless overhead and unnecessarily fragile. On Mon, Mar 15, 2021 at 11:40 PM Amit Saha wrote: > > > On Tue, 16 Mar 2021, 9:37 am Sharan Guhan, wrote: > >> Hi Experts,

Re: [go-nuts] Error while executing exec.command

2021-03-15 Thread Amit Saha
On Tue, 16 Mar 2021, 9:37 am Sharan Guhan, wrote: > Hi Experts, > > I am relatively new to GOLANG and trying a simple program as below which > is failing in fetching the output of a file, which works otherwise on the > command prompt: > > Lang : GOLANG > OS : Linux/Centos > Problem : Using

[go-nuts] Error while executing exec.command

2021-03-15 Thread Sharan Guhan
Hi Experts, I am relatively new to GOLANG and trying a simple program as below which is failing in fetching the output of a file, which works otherwise on the command prompt: Lang : GOLANG OS : Linux/Centos Problem : Using exec.command to get the output of a certain file Error: Getting no such

[go-nuts] How to implement localhost proxy which injects Proxy-Authorization header to incoming request and sends it to another remote proxy with Go?

2021-03-15 Thread Hugo Bollon
Hi! I'm actually building an automation tool based on Selenium with Go called IGopher and I have had a few requests to implement native proxy support. However, I am facing an issue with those with authentication... I can't send the proxy credentials to Chrome and without them it asks through

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

2021-03-15 Thread Ian Lance Taylor
On Mon, Mar 15, 2021 at 3:11 PM atd...@gmail.com wrote: > > I am in favor of the proposal but I think that accounting for popularity > votes is not a good measure of things. > A lot of people are at various stages of their technical journey in computer > science and engineering and there has to

[go-nuts] Re: encoding/html package to generate html markup programmatically

2021-03-15 Thread atd...@gmail.com
Oh, you might be my savior ! :) I starred it and am going to look into it. Looks quite promising! On Monday, March 15, 2021 at 6:52:58 PM UTC+1 michael...@gmail.com wrote: > goht might be what you're > looking for. > > On Sunday, March 14, 2021 at

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

2021-03-15 Thread atd...@gmail.com
I am in favor of the proposal but I think that accounting for popularity votes is not a good measure of things. A lot of people are at various stages of their technical journey in computer science and engineering and there has to be a weight given to the more technical opinions that is not

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

2021-03-15 Thread Ian Lance Taylor
On Mon, Mar 15, 2021 at 5:08 AM Space A. wrote: > > > For example, the multiple proposals that flowed out of > https://go.googlesource.com/proposal/+/master/design/go2draft-error-handling-overview.md. > None of them have been adopted. > > I remember what was happening to "try" error handling

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

2021-03-15 Thread Wojciech S. Czarnecki
Dnia 2021-03-15, o godz. 15:08:22 "Space A." napisał(a): > And what's happened to a new "generics" proposal, it also got a lot of > critics Apparently not that lot. Second (publicized) design was for me, and likely for many other "vocal critics", good enough. My personal (and fresh)

Re: [go-nuts] insane idea to eliminate CGO latency

2021-03-15 Thread Andy Balholm
By the way, this existed at one point. Early versions of the Go toolchain included C compilers (6c, 8c, etc.) designed to work together nicely with Go code. If I remember right, most of the Go runtime was written in C, and compiled with these compilers. But they used an unusual dialect of C

Re: [go-nuts] running tests against benchmarks

2021-03-15 Thread Jeremy French
Yes, I thought of something similar. You could certainly save/write the results of a benchmark to any version of a db/textfile, and then run another program to analyze it and do whatever you like with it. That just seems like unnecessary overhead. It would seem that since the test is just a

Re: [go-nuts] insane idea to eliminate CGO latency

2021-03-15 Thread Robert Engels
Totally agree and that was my point. If the desire is to speed up calls to C there are many options - done explicit (like marking calls non blocking), or implicit - once a routine makes a “unknown” C native call that routine is always bound to a dedicated thread - clearly you are trading

Re: [go-nuts] insane idea to eliminate CGO latency

2021-03-15 Thread t hepudds
Hello fellow gophers, Here is a helpful link that gives an overview of some of what impacts cgo performance, including the slides have pointers into the code for anyone interested in going deeper: https://speakerdeck.com/filosottile/why-cgo-is-slow-at-capitalgo-2018 That was a 2018

Re: [go-nuts] insane idea to eliminate CGO latency

2021-03-15 Thread Ian Lance Taylor
On Mon, Mar 15, 2021 at 12:17 PM Jason E. Aten wrote: > > On Monday, March 15, 2021 at 12:58:38 PM UTC-5 Ian Lance Taylor wrote: >> >> I think it is too strong to say that the scheduler is the "bottleneck" >> in calling C code, but I believe that the operations required to tell >> the scheduler

Re: [go-nuts] insane idea to eliminate CGO latency

2021-03-15 Thread Jason E. Aten
On Monday, March 15, 2021 at 12:58:38 PM UTC-5 Ian Lance Taylor wrote: > I think it is too strong to say that the scheduler is the "bottleneck" > in calling C code, but I believe that the operations required to tell > the scheduler what is happening to the goroutine are the most costly > parts

Re: [go-nuts] running tests against benchmarks

2021-03-15 Thread Marcin Romaszewicz
What you want to do is common, but it's application-specific enough that there aren't so many generalized solutions. What I've always done is create a Go program which takes a while to run (I shoot for at least a minute) which runs your BeefyFunc in various ways that make sense to you, then I make

Re: [go-nuts] insane idea to eliminate CGO latency

2021-03-15 Thread Ian Lance Taylor
On Sun, Mar 14, 2021 at 7:54 PM Robert Engels wrote: > > True. I was collapsing the two because why does Go care. If the routine is in > a C native call don’t switch the routine assigned to the thread. Similarly. > If the thread is in C native it can’t affect stacks / heap structures - so >

[go-nuts] Re: encoding/html package to generate html markup programmatically

2021-03-15 Thread Michael Ellis
goht might be what you're looking for. On Sunday, March 14, 2021 at 7:36:52 PM UTC-4 atd...@gmail.com wrote: > Hi, > > I am currently thinking about implementing SSR for a Go client-side > framework. > Not only that but I would like to be able to

[go-nuts] running tests against benchmarks

2021-03-15 Thread Jeremy French
I keep running into this solution to a particular problem, but when I go to search on how to do it, I find that not only are there seemingly no solutions out there in search-results-land, there doesn't seem to be anyone else even asking about it. This then leads me to suspect, that I'm going

Re: [go-nuts] insane idea to eliminate CGO latency

2021-03-15 Thread 'drc...@google.com' via golang-nuts
Go "cares" because in Go it's common for a single OS thread to correspond to 25-100% of runnable goroutines. So the accounting for "how many OS threads are available to run goroutines" tends to be fine-grained, otherwise weird failure-to-schedule bugs can occur. It's likely it could be

Re: [go-nuts] Why do type aliases change behaviour (i.e. json.Unmarshal)?

2021-03-15 Thread cpu...@gmail.com
Thank you @Michel. Disturbing that I keep making the same mistake again... On Monday, March 15, 2021 at 2:05:53 PM UTC+1 mlevi...@gmail.com wrote: > This is because per the Go spec: > https://golang.org/ref/spec#Type_declarations > You're not creating an alias to Token, but defining a new type

[go-nuts] Re: [ANN] New german translations

2021-03-15 Thread Haddock
I agree that Quellcode or Quelltext are the best transalations IMHO other than just using Code HaWe schrieb am Sonntag, 14. März 2021 um 09:11:14 UTC+1: > Hello Tim. > > Translating, that's a hobbyhorse I ride now and then. > (Learn something new about Go and improve your English and German in

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

2021-03-15 Thread 'Axel Wagner' via golang-nuts
On Mon, Mar 15, 2021 at 2:19 PM Kevin Chadwick wrote: > Whilst you have wrongly called some things in this thread irrelevant. > To be clear: I meant they are not relevant to the discussion of the property that a zero value is represented by 0 bytes. I explained why (they are questions about the

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

2021-03-15 Thread Kevin Chadwick
On 3/13/21 5:27 PM, 'Axel Wagner' via golang-nuts wrote: >   > I'm once again not sure what your objective is here. No one is trying to argue > that it is impossible to introduce semantics like you propose. > We are only trying to give you the reasons why that's currently not done. > > You can

Re: [go-nuts] Why do type aliases change behaviour (i.e. json.Unmarshal)?

2021-03-15 Thread Jan Mercl
On Mon, Mar 15, 2021 at 1:49 PM cpu...@gmail.com wrote: > type WrappedToken Token Note that this is not a type alias. WrappedToken is a new type. Even if its underlying type is Token, WrappedToken does not automatically have any methods of Token. > Only to find out, that unmarshaling a

Re: [go-nuts] Why do type aliases change behaviour (i.e. json.Unmarshal)?

2021-03-15 Thread Levieux Michel
This is because per the Go spec: https://golang.org/ref/spec#Type_declarations You're not creating an alias to Token, but defining a new type from it. If what you are looking for is an alias (meaning to have the "WrappedToken" identifier refer to the exact same type as Token), you need to do:

[go-nuts] Why do type aliases change behaviour (i.e. json.Unmarshal)?

2021-03-15 Thread cpu...@gmail.com
I've just tried doing something like this in my code: // Token is an OAuth2 token which includes decoding the expires_in attribute type Token struct { oauth2.Token ExpiresIn int `json:"expires_in"` // expiration time in seconds } func (t *Token) UnmarshalJSON(data []byte) error { ... } type

[go-nuts] %v for []string{} and []string{""}

2021-03-15 Thread Brian Candler
I was slightly surprised to discover that the Print() output for an empty slice, and a 1-element slice containing the empty string, are the same: https://play.golang.org/p/btkzgk4LMT9 It does follow logically from the rules . I guess I need to train

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

2021-03-15 Thread Space A.
Entropy tends to grow. Good things tend to become less good and even bad over time. This is how the Universe works. Does C++ become a better language by adding more and more features? What about Java? What makes you think that people who were behind other languages weren't doing the same as what

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

2021-03-15 Thread Space A.
> For example, the multiple proposals that flowed out of https://go.googlesource.com/proposal/+/master/design/go2draft-error-handling-overview.md . None of them have been adopted. I remember what was happening to "try" error handling proposal. It was withdrawn only because of active resistance

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

2021-03-15 Thread Space A.
Sorry, of course it's Robert, my mistake. пн, 15 мар. 2021 г. в 05:30, Ian Lance Taylor : > On Sat, Mar 13, 2021 at 9:25 AM Space A. wrote: > > > > And Russ didn't write academic paper regarding it (before accepting > proposal in less than a month after it was published). =) > > There may be

Re: [go-nuts] Analysis check for leaked pointers to loop variable address

2021-03-15 Thread Barisere Jonathan
That's correct. I've found that it's most often a mistake when working with slices. But for maps, there is some use for it, such as relying on maps being unordered to select random values from the map, although there should be a better way to do that. An analysis check for this should produce a

[go-nuts] Re: yet another code gen: specialized datastructure

2021-03-15 Thread Michał Matczuk
I invite you to take a look at [1] a bazel-free version of Google go_generics tool released with gVisor project. It is used to make [2]. [1] https://github.com/mmatczuk/go_generics [2] https://github.com/scylladb/go-set

Re: [go-nuts] Analysis check for leaked pointers to loop variable address

2021-03-15 Thread Jan Mercl
On Mon, Mar 15, 2021 at 3:03 AM Barisere Jonathan wrote: > I think this mistake can be caught by code analysis tools, but I don't know > of any that catches these. IMO the problem is that while sometimes it's a mistake, in some other cases it is not and it is perfectly good, reasonable code.