Re: [go-nuts] Why is it forbidden to add methods to an existing type?

2022-04-06 Thread Brian Candler
I agree, and there's a clear benefit that it's harder to dereference a nil interface than a nil pointer, when that interface has no methods. The problem is that statically it doesn't tell you anything about the possible contained type. In comparison, a pointer tells you exactly the type contai

[go-nuts] How go.work knows which module refers to which folder

2022-04-06 Thread 'Jack Li' via golang-nuts
Hi group, In the go.mod replace way, there’s a one-to-one mapping relationship, for example, the module example.com/hello is mapped to folder …/hello ``` $ go mod edit -replace example.com/hello=../hello $ view go.mod replace example.com/hello => ../hello  $ ``` Now with the go.work way. If

[go-nuts] Execution of goroutines

2022-04-06 Thread Guido Millenaar
Hi, As a fun way of getting into Go I decided to create a "random" number generator by timing a number of requests to a specific URL, and reducing the results to one number. For practice pusposes I made a "naive" version with just a for loop and a version that uses goroutines. As I am interest

[go-nuts] Handle 1 million concurrent connections with 50 lines Go code

2022-04-06 Thread 'Jack Li' via golang-nuts
Hi group, I am going through this page: https://studygolang.com/articles/22820 , It claims that the 50 lines of Go code handles 1 million concurrent connections from network clients, on 1 single server machine with a 4-Core CPU and 16G memory. Does the package net already utilize IO Multiple

Re: [go-nuts] Handle 1 million concurrent connections with 50 lines Go code

2022-04-06 Thread Ian Lance Taylor
On Wed, Apr 6, 2022 at 6:43 AM 'Jack Li' via golang-nuts wrote: > > I am going through this page: https://studygolang.com/articles/22820 , It > claims that the 50 lines of Go code handles 1 million concurrent connections > from network clients, on 1 single server machine with a 4-Core CPU and 16

[go-nuts] Re: Handle 1 million concurrent connections with 50 lines Go code

2022-04-06 Thread Amnon
Yes, the Go runtime does use epoll internally and schedules gorountines when their data is available. See https://github.com/golang/go/blob/17b2fb1b656a275906b5071c562439d50a27f167/src/runtime/netpoll_epoll.go It does scale nicely and can handle tens of thousands or even hundreds of thousands o

Re: [go-nuts] Handle 1 million concurrent connections with 50 lines Go code

2022-04-06 Thread Robert Engels
Yes. Go uses “green threads” with its own scheduler and uses facilities like epoll under the covers. > On Apr 6, 2022, at 8:43 AM, 'Jack Li' via golang-nuts > wrote: > >  > Hi group, > > I am going through this page: https://studygolang.com/articles/22820 , It > claims that the 50 lines of

[go-nuts] Re: How go.work knows which module refers to which folder

2022-04-06 Thread thepud...@gmail.com
Hi there, I might be misunderstanding your question, but a 'use' directive in a go.work file points to a directory. In your example, there would not be any ambiguity -- 'use ./hello' in a go.work file would refer to whatever module you have located in the 'hello' directory in your local files

Re:[go-nuts] Re: How go.work knows which module refers to which folder

2022-04-06 Thread 'Jack Li' via golang-nuts
Thanks. I think I may get it. If there's go.work, the `import example.com/module` will try those local directories in go.work first. If not found, it will try online repositories. And module names like this `example.com/module`, `github.com/golang/glog`, etc. are unique, so there will be no

[go-nuts] Re: Execution of goroutines

2022-04-06 Thread Brian Candler
> Is there maybe something blocking involved in http.Get()? Yes of course - first establishing a TCP connection across the network, then sending data over it and waiting for the response. Each of these is a point where the goroutine gets descheduled because it has nothing more to do; it's waiti

[go-nuts] I cannot generate public keys in sequence.

2022-04-06 Thread ass sds
func Public(PrivateKey string) (publicKey string) { var e ecdsa.PrivateKey e.D, _ = new(big.Int).SetString(PrivateKey, 16) e.PublicKey.Curve = secp256k1.S256() e.PublicKey.X, e.PublicKey.Y = e.PublicKey.Curve.ScalarBaseMult(e.D.Bytes()) return fmt.Sprintf("%x", elliptic.MarshalCompressed(secp25

[go-nuts] Re: I cannot generate public keys in sequence.

2022-04-06 Thread Brian Candler
If you have a problem using the go-ethereum library then you're probably best asking at the tracker or discussion group for that software. However, the error message seems pretty clear: you're trying to pass a value of type []byte to a function which takes a string. You can convert one to the

[go-nuts] Re: go mod tidy doesn't rewrite go.mod file (shows go: warning "all" matched no packages)

2022-04-06 Thread 'Bryan C. Mills' via golang-nuts
Do you have a go.work file? If so, does it include the module in that directory? (Compare https://go.dev/issue/51604.) What do `go env GOMOD` and `go env GOWORK` report? On Friday, April 1, 2022 at 10:05:57 AM UTC-4 vaastav...@gmail.com wrote: > There is definitely source code in that folder. T

Re: [go-nuts] Can generics save virtual function calls?

2022-04-06 Thread Amit Lavon
Thank you! On Tuesday, April 5, 2022 at 10:05:40 PM UTC+3 Ian Lance Taylor wrote: > On Tue, Apr 5, 2022 at 11:05 AM Amit Lavon wrote: > > > > When we use an interface as a type parameter, does it mean that calls to > that interface will be replaced with calls to the concrete type? > > > > To de

[go-nuts] TMTP messaging protocol

2022-04-06 Thread Liam Breck
TMTP is a protocol [1] to let Internet sites message customers/members directly, instead of unreliable, insecure email or costly custom apps. https://mnmnotmail.org https://twitter.com/mnmnotmail The open source client [2] and server [3] are written in Go. The client UI runs in a localhost browse

[go-nuts] Bug? go/src/all.bash on master branch fails in go/build test with Go1.18

2022-04-06 Thread tenkoh
I'm unsure whether this is a bug or not, so let me ask here. *### What version of Go are you using (`go version`)?* go version go1.18 linux/arm64 *### Does this issue reproduce with the latest release?* Yes *### What operating system and processor architecture are you using (`go env`)?* using d

Re: [go-nuts] Bug? go/src/all.bash on master branch fails in go/build test with Go1.18

2022-04-06 Thread 'Axel Wagner' via golang-nuts
The master branch is used for the active development and not for general consumption. It is not unusual for builds/tests to fail on it occasionally. You can always check the build dashboard to see if that's currently the case. Generally, I would tend to assume that there

[go-nuts] Re: TMTP messaging protocol

2022-04-06 Thread Brian Candler
Cross-ref to previous thread: https://groups.google.com/g/golang-nuts/c/PLPjo5w3zTg On Wednesday, 6 April 2022 at 22:06:28 UTC+1 Liam wrote: > TMTP is a protocol [1] to let Internet sites message customers/members > directly, instead of unreliable, insecure email or costly custom apps. > > http