[go-nuts] multiple rangefunc iterators: restart?

2024-05-23 Thread Rory Campbell-Lange
I've been playing with with rangefunc experiment, with help from 
https://go.dev/wiki/RangefuncExperiment and the possible idioms that might come 
out of it (https://blog.perfects.engineering/go_range_over_funcs is a good 
read).

One somewhat eccentric use of nested iterators I built in the past in python 
was turning an SQL widerows or domain aggregate result into a set of nested 
objects, so one could use the results in something like the following way:

for p in people:
for c in p.cars:
for t in c.tickets:
print("person {} in car {} got ticket {}", p, c, t)

While I was able to get a very janky version of this type of behaviour with 
https://go.dev/play/p/gFUcKNSrbMV?v=gotip this only has an iterator on the left 
hand side and series of nested structs through slices. My attempts to use more 
iterators (for cars and tickets) fails as these of course stop after the first 
set of cars and tickets respectively have been yielded.

I realise this is a contrived example, but I wonder if there might be more 
general cases where iterators could be stopped and restarted. (The docs to 
iter.Pull suggest next() and stop() are non-resettable also.) Perhaps there 
could be hidden new iter.Seq constructors in the container for when the cars 
and tickets iterators are exhausted...hmm...

I'd be grateful for any thoughts about this casual and hypothetical case, 
although I guess it could be helpful for something like retrieving nested data 
from an sql cursor efficiently.

Cheers
Rory


That code above turns:

a a1 a2 b1 b2 b3 c1 c2 c3
a a1 a2 b1 b2 b3 c4 c5 c6
a a1 a2 b1 b2 b3 c7 c8 c9
a a1 a2 b4 b5 b6 c10 c11 c12
d d1 d2 e1 e2 e3 f1 f2 f3
d d1 d2 e1 e2 e3 f4 f5 f6
g g1 g2 h1 h2 h3 i1 i2 i3

into:

[a a1 a2]
>  [b1 b2 b3]
> >  [c1 c2 c3]
> >  [c4 c5 c6]
> >  [c7 c8 c9]
>  [b4 b5 b6]
> >  [c10 c11 c12]
[d d1 d2]
>  [e1 e2 e3]
> >  [f1 f2 f3]
> >  [f4 f5 f6]
[g g1 g2]
>  [h1 h2 h3]
> >  [i1 i2 i3]

called like this:

for a := range collection.Iter() { // iter.Seq
fmt.Println(a.r)
for _, b := range a.s {// slice -- could be iter.Seq?
fmt.Println("> ", b.r)
for _, c := range b.s {// slice -- could be 
iter.Seq?
fmt.Println("> > ", c.r)
}
}
}

-- 
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 
https://groups.google.com/d/msgid/golang-nuts/Zk94CqLUJ6fJjmuA%40campbell-lange.net.


Re: [go-nuts] Re: Call the .net dlls into the golang

2024-05-23 Thread 'Brian Candler' via golang-nuts
"try building at the command line"

That's your clue. You'll most likely get a meaningful error message on 
stderr, which your IDE is hiding.

On Thursday 23 May 2024 at 13:47:10 UTC+1 Pavan Kumar A R wrote:

> Hello , 
>
> I am try to call the c program in the golang , but i am getting the issue 
> .  please see the error message :
> package main
>
> go list failed to return CompiledGoFiles. This may indicate failure to 
> perform cgo processing; try building at the command line. See 
> https://golang.org/issue/38990.go list
> View Problem (Alt+F8)
>
>
> //#cgo LDFLAGS: -L. -llibCWrapper-win64 -Wl,-rpath,.
> //#include "ealApiLib.h"
>
> import "C"
> import "fmt"
>
> func main() {
>
> result := C.Connect("192.168.1.1")
>
> fmt.Println("connection success" + result)
>
> }
>
>
>
> On Thursday 23 May 2024 at 02:53:12 UTC+5:30 peterGo wrote:
>
>> cgo command
>> https://pkg.go.dev/cmd/cgo
>> Cgo enables the creation of Go packages that call C code.
>>
>> On Wednesday, May 22, 2024 at 4:41:13 PM UTC-4 Carla Pfaff wrote:
>>
>>> Yes, you can call C functions from Go, it's called Cgo: 
>>> https://go.dev/blog/cgo
>>>
>>> On Wednesday 22 May 2024 at 18:04:19 UTC+2 Pavan Kumar A R wrote:
>>>

> Okay,  it's possible to call the C program to Golang. Because I also 
> have the C platform dlls and the C platform dlls  we using in the cross 
> platform mono and in the mono internally call the.net dlls function , 
> can I use the C program dlls in Golang?  
>


-- 
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 
https://groups.google.com/d/msgid/golang-nuts/21db8561-176e-4857-a904-8bda3c226ab3n%40googlegroups.com.


Re: [go-nuts] Re: Call the .net dlls into the golang

2024-05-23 Thread Pavan Kumar A R
Hello , 

I am try to call the c program in the golang , but i am getting the issue 
.  please see the error message :
package main

go list failed to return CompiledGoFiles. This may indicate failure to 
perform cgo processing; try building at the command line. See 
https://golang.org/issue/38990.go list
View Problem (Alt+F8)


//#cgo LDFLAGS: -L. -llibCWrapper-win64 -Wl,-rpath,.
//#include "ealApiLib.h"

import "C"
import "fmt"

func main() {

result := C.Connect("192.168.1.1")

fmt.Println("connection success" + result)

}



On Thursday 23 May 2024 at 02:53:12 UTC+5:30 peterGo wrote:

> cgo command
> https://pkg.go.dev/cmd/cgo
> Cgo enables the creation of Go packages that call C code.
>
> On Wednesday, May 22, 2024 at 4:41:13 PM UTC-4 Carla Pfaff wrote:
>
>> Yes, you can call C functions from Go, it's called Cgo: 
>> https://go.dev/blog/cgo
>>
>> On Wednesday 22 May 2024 at 18:04:19 UTC+2 Pavan Kumar A R wrote:
>>
>>>
 Okay,  it's possible to call the C program to Golang. Because I also 
 have the C platform dlls and the C platform dlls  we using in the cross 
 platform mono and in the mono internally call the.net dlls function , 
 can I use the C program dlls in Golang?  

>>>

-- 
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 
https://groups.google.com/d/msgid/golang-nuts/d8665110-07f3-4f0d-8e14-49900cd4b6abn%40googlegroups.com.