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

2022-03-25 Thread Sam Hughes
My workaround like is something like `type String struct{string}. It can be reasonably treated as a string for most cases in which as string is needed, and it lets you convert back conveniently from any scope in which it's reasonable for your program to know the difference. On Friday, March 18,

Re: [go-nuts] Is there any way to produce etcd watch chan be closed

2022-03-25 Thread Sam Hughes
As written above, if that's the main thread, it is guaranteed to freeze in a deadlock every time. I don't see a goroutine kicked off, so I'm assuming you're trying to run that on the main thread, and you will be 100%, always, forever stuck on the `case wch := <- ach {` line. Channel reads are

[go-nuts] Re: I have just published my iterator library iter_go : migrated for generics

2022-03-25 Thread Sam Hughes
Hey. I'm a rando internet jerk that just wrote you an issue! I know I can't quite use your package, but I did point out an easy improvement I think you could make, that'd make stacking iterators into pipelines a little easier. On Wednesday, March 23, 2022 at 5:14:10 AM UTC-5 Serge Hulne wrote:

Re: [go-nuts] How the bmap structure in runtime/map.go dynamically extended during compilation?

2022-03-25 Thread Maksadbek
Yes, this is exactly what I was searching for. Thank you! On Friday, 25 March 2022 at 21:51:27 UTC+3 Ian Lance Taylor wrote: > On Fri, Mar 25, 2022 at 11:42 AM Maksadbek wrote: > > > > I've been reading the map internals in Go and came across into following > structure in source code: > > > > h

Re: [go-nuts] How the bmap structure in runtime/map.go dynamically extended during compilation?

2022-03-25 Thread Ian Lance Taylor
On Fri, Mar 25, 2022 at 11:42 AM Maksadbek wrote: > > I've been reading the map internals in Go and came across into following > structure in source code: > > https://github.com/golang/go/blob/master/src/runtime/map.go#L150 > > // A bucket for a Go map. > type bmap struct { > // tophash generally

Re: [go-nuts] Is there any way to produce etcd watch chan be closed

2022-03-25 Thread Ian Lance Taylor
On Fri, Mar 25, 2022 at 11:41 AM 袁成若 wrote: > > I met a problem about etcd watch channel. seems that be closed, but i can > not reproduce it. > > like this: > > ``` > for { > ach := etcdClientV3.Watch(context.Background(), "/test", > clientv3.WithPrefix()) > for { > select {

[go-nuts] LotusDB - A fast kv database in Go

2022-03-25 Thread Rose Duan
I write a new kv storage named LotusDB, an alternative to Badger or bbolt in Go. Github:https://github.com/flower-corp/lotusdb Key features: - Combine the advantages of LSM and B+ tree - Fast read/write performance - Much lower read and space amplification tha

[go-nuts] How the bmap structure in runtime/map.go dynamically extended during compilation?

2022-03-25 Thread Maksadbek
I've been reading the map internals in Go and came across into following structure in source code: https://github.com/golang/go/blob/master/src/runtime/map.go#L150 // A bucket for a Go map. type bmap struct { // tophash generally contains the top byte of the hash value // for each key in this buc

[go-nuts] Re: New edition of the Go Programming Language comming soon ?

2022-03-25 Thread tmack8080
Page XV: "We assume that you have programmed in one or more languages, whether compiled like C, C++, and Java, or interpreted like Python, Ruby, and JavaScript, so we won't spell out everything as if for a total beginner." On Monday, March 14, 2022 at 12:11:34 PM UTC-4 r...@rwx.gg wrote: > As a

Re: [go-nuts] Looked at using Go ... nil/SEGV really bothered me .. Go2 Proposal?

2022-03-25 Thread 'Michael Toy' via golang-nuts
The discussion is quite informative for me to read, thanks for responding. Go uses nil in a way which I don't quite yet grok, and so I had no idea if it was even a reasonable thing to wish for. Today I am writing in Typescript, and the way null is integrated into the type system now (after a wh

[go-nuts] Is there any way to produce etcd watch chan be closed

2022-03-25 Thread 袁成若
I met a problem about etcd watch channel. seems that be closed, but i can not reproduce it. like this: ``` for { ach := etcdClientV3.Watch(context.Background(), "/test", clientv3.WithPrefix()) for { select { case wch := <- ach { fmt.Println(

Re: [go-nuts] all goroutines are asleep - deadlock!

2022-03-25 Thread Tong Sun
Oh, thanks for the explain and pointing out `go vet` for future problems. Thanks! On Friday, March 25, 2022 at 12:08:39 PM UTC-4 jake...@gmail.com wrote: > The WaitGroup Documentation says " A > WaitGroup must not be copied after first use.". > > You are pa

Re: [go-nuts] all goroutines are asleep - deadlock!

2022-03-25 Thread jake...@gmail.com
The WaitGroup Documentation says " A WaitGroup must not be copied after first use.". You are passing around and calling choppingActivity by value, so it is being copied after Add() is called, and again each call to choppingAction() and choppingSimulation().

Re: [go-nuts] all goroutines are asleep - deadlock!

2022-03-25 Thread Tong Sun
*Re-using the old thread for a new problem that I'm getting:* fatal error: all goroutines are asleep - deadlock! I rewrote my https://github.com/suntong/lang/blob/master/lang/Go/src/sys/butchers.go files from procedure based to OO based, as https://github.com/suntong/lang/tree/master/lang/Go/sr

Re: [go-nuts] Mathematical operations - the generics way

2022-03-25 Thread Paul Hankin
I don't know if it's important to you, but your Max[float64] isn't compatible with math.Max in the standard library. For example, Max[float64](NaN, 1) returns 1 rather than NaN. On Tuesday, 22 March 2022 at 16:58:40 UTC+1 esi...@gmail.com wrote: > I found a working version meantime. > > // Max r