Re: [go-nuts] Golang import issue .

2022-07-19 Thread Gopal M
Hi Sunday Ajayi, Pl avoid screenshots... :-) Finding it difficult to decode / Seems to be no full information available to understand. Will you be able to send the zipped project ? On Tue, Jul 19, 2022 at 9:44 PM Sunday Ajayi wrote: > Hi Team, > > I am having an issue import functions into

Re: [go-nuts] Re: duration^2

2022-07-19 Thread 'Dan Kortschak' via golang-nuts
On Tue, 2022-07-19 at 09:24 -0700, Amnon wrote: > > time.NewTicker( time.Duration(n) * time.Second )  ok : duration > > * duration [s^2] square-seconds ? > > Yes, this bothers the inner Physicist in me too. > But you can only multiply numbers if they are of the same type... With a small

[go-nuts] Re: goroutine private / local var/const

2022-07-19 Thread peterGo
Are you looking for somthing like this? https://go.dev/play/p/_nERkkLC94h peter On Tuesday, July 19, 2022 at 12:14:14 PM UTC-4 agra...@googlemail.com wrote: > hi, > > for i=0;i<10;i++ { go func () { /* const c=i OR var v=i */ > fmt.Println("f:beg i=",i) // here c or v instead > // action >

[go-nuts] Re: duration^2

2022-07-19 Thread Amnon
On Tuesday, 19 July 2022 at 17:14:19 UTC+1 agra...@googlemail.com wrote: > hello, > i am new to everything is new in programming-heaven. old-c-guy. and i > thought it`s time to learn something most-modern .. > Welcome! Go is a great language for old-c-guys (and girls). Go was, in fact

[go-nuts] duration^2

2022-07-19 Thread 'andreas graeper' via golang-nuts
hello, i am new to everything is new in programming-heaven. old-c-guy. and i thought it`s time to learn something most-modern .. time.NewTicker( time.Second ) ok time.NewTicker( 5 * time.Second ) ok var n int = 5 time.NewTicker( n * time.Second ) error : int * duration

[go-nuts] goroutine private / local var/const

2022-07-19 Thread 'andreas graeper' via golang-nuts
hi, for i=0;i<10;i++ { go func () { /* const c=i OR var v=i */ fmt.Println("f:beg i=",i) // here c or v instead // action fmt.Println("f:end i=",i) // here c or v instead }} when this routines get interrupted then beg-i and end-i differ now i want at the beginning of the routine a const copy

Re: [go-nuts] Issues with time.Time

2022-07-19 Thread Slawomir Pryczek
Have you tried starting a simple thread which will update some variable every 100ms (for example), and then just get value of this variable? Using atomic functions. I believe memcached was 'caching' calls to get time this way and it won't probably be very accurate (as we don't have hard

[go-nuts] Re: Best way of implementing generic binary search?

2022-07-19 Thread Brian Candler
You don't need a compare method on your type. You can just pass a func(T, T) bool to your search function. In fact, the standard library already has this, except implemented in terms of slice indexes only, rather than a slice of generic type. https://pkg.go.dev/sort#Search You could always

Re: [go-nuts] Best way of implementing generic binary search?

2022-07-19 Thread Martin Schnabel
Hi, there is an experimental package golang.org/x/exp/slices which has a generic binary search. I have not much to add but hope it helps. https://pkg.go.dev/golang.org/x/exp/slices https://cs.opensource.google/go/x/exp/+/79cabaa2:slices/sort.go;l=64 On 7/19/22 14:53, Slawomir Pryczek wrote: Hi

[go-nuts] Best way of implementing generic binary search?

2022-07-19 Thread Slawomir Pryczek
Hi Guys, is it possible to implement generic, efficient binary search using generics or interfaces. So i'll have some index, and data inside single struct and then could just define a comparison function between 2 variables of same type index which will return bool. Will have 20-30 million