Re: [go-nuts] Re: [generics] Print[T Stringer](s []T) vs Print(s []Stringer)

2020-12-26 Thread K. Alex Mills
While it depends on the final generics implementation, my understanding of how things stand now is that Print would compile down to a separate chunk of binary for each type T that is used. For instance, if you used Print[A] and Print[B] in your code, they would each refer to separate binary impleme

Re: [go-nuts] Re: [generics] Print[T Stringer](s []T) vs Print(s []Stringer)

2020-12-26 Thread Elliot
If we remove slice from OP's example: https://go2goplay.golang.org/p/KSJpRw1Lrmm func Print[T Stringer](s T) { fmt.Print(s.String()) } func Printi(s Stringer) { fmt.Print(s.String()) } Are these two equivalent? When should one be chosen over the other? On Thursday, 24 December 2020 at

[go-nuts] datastore.RunInTransaction

2020-12-26 Thread Jeff
I was curious how datastore.RunInTransaction was implemented in comparison to the Transaction method set so I took quick look at the source code. However, I hope I am simply misunderstanding the source code for datastore.RunInTransaction at: https://github.com/googleapis/google-cloud-go/blob/d

Re: [go-nuts] Java version of keydb

2020-12-26 Thread robert engels
Ask and ye shall receive… So, first with running using the GraalVM JDK 11 Community Edition: insert time 1000 records = 19305ms, usec per op 1.9305 close time 12313ms scan time 10695ms, usec per op 1.0695 scan time 50% 461ms, usec per op 0.922 random access time 12.014us per get close with me

Re: [go-nuts] [go2go] "interface contains type constraints"

2020-12-26 Thread 'Axel Wagner' via golang-nuts
PS: You might be interested in the discussion about whether or not to allow this in the future: https://github.com/golang/go/issues/41716 On Sat, Dec 26, 2020 at 11:20 PM Axel Wagner wrote: > `Union[T, error]` is defined as > > interface { > type T, error > } > > An interface containing a ty

Re: [go-nuts] [go2go] "interface contains type constraints"

2020-12-26 Thread 'Axel Wagner' via golang-nuts
`Union[T, error]` is defined as interface { type T, error } An interface containing a type-list can only be used as a constraint. However, you are using it as a type in several places. On Sat, Dec 26, 2020 at 10:22 PM thwd wrote: > My (short) code: > https://go2goplay.golang.org/p/J4Ovyt-4

[go-nuts] [go2go] "interface contains type constraints"

2020-12-26 Thread thwd
My (short) code: https://go2goplay.golang.org/p/J4Ovyt-4xXN The spec: https://go.googlesource.com/proposal/+/refs/heads/master/design/go2draft-type-parameters.md The errors: prog.go2:7:30: interface contains type constraints (T, error) prog.go2:19:32: interface contains type constraints (T, stru

[go-nuts] Re: json objects

2020-12-26 Thread 钟晓键
In fact, the JSON content you pasted here is NOT valid, cause there shouldn't be more than one root element in a single JSON file (you can try online JSON validator to validate your JSON file). 在2020年12月26日星期六 UTC+8 下午11:06:22 写道: > how to unmarshal

Re: [go-nuts] Re: Generics, please go away!

2020-12-26 Thread Henrik Johansson
Who said anything about gold standards? This is about generics going away and I would argue that many if not all computer languages that have generics also have a user base that is overwhelmingly in favor of it compared to it not existing. Perhaps another flavor of generics would be better but bein

Re: [go-nuts] json objects

2020-12-26 Thread Martin Schnabel
hi hamsa, first of all: it is usually frowned upon to send text as pictures. so please copy text as text in the future. the are people with terminal mail clients or visually impaired using screen readers. the data in your example is neither valid json value nor a valid json stream. either you

Re: [go-nuts] json objects

2020-12-26 Thread Charles Radke
I think you probably to unmarshal into a []book. From: on behalf of Hamsa Hesham Date: Saturday, December 26, 2020 at 10:06 AM To: golang-nuts Subject: [go-nuts] json objects how to unmarshal more than one json object .. Here is the code data, err := ioutil.ReadFile("file.txt") checkE

Re: [go-nuts] Re: Generics, please go away!

2020-12-26 Thread Jeremy French
If Java and C++ were the perfection of computer language evolution, then there would be no need for Go. Using your predecessors as the gold standard makes no sense, because if they were, then no other iteration would be necessary. We wouldn't be having this discussion, because there would be no Go.

[go-nuts] json objects

2020-12-26 Thread Hamsa Hesham
how to unmarshal more than one json object .. Here is the code data, err := ioutil.ReadFile("file.txt") checkError(err) x:=string(data) fmt.Println(x) var b1 book err1:=json.Unmarshal(data,&b1) fmt.Printf("Books : %+v", b1) checkError(err1) if b1.ID==ID

[go-nuts] Re: Generics, please go away!

2020-12-26 Thread wilk
On 26-12-2020, Christian Staffa wrote: > I would rather have a survey with generics specific question that would she= > d a better light to this topic. at least now, after following this discussi= > on. i also think that it could be good to add it but is it worth when it al= > so adds complexity? t

[go-nuts] Progress bar library

2020-12-26 Thread erma...@gmail.com
Hello, this my progress bar library: https://github.com/ermanimer/progress_bar Best regards -- 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.

Re: [go-nuts] Re: Generics, please go away!

2020-12-26 Thread Christian Staffa
I would rather have a survey with generics specific question that would shed a better light to this topic. at least now, after following this discussion. i also think that it could be good to add it but is it worth when it also adds complexity? then i would say no thank you. go is powerful and s