[go-nuts] When net package is imported building binary with CGO generate error

2023-11-02 Thread sbezverk
Hello, I came across a situation when “net” package is imported regardless directly or indirectly via another package, go build generates these errors: /sw/packages/go/1.19.4/src/net/cgo_linux.go:20:59: could not determine kind of name for C.AI_ALL

[go-nuts] Re: cgo.go: multiple definition of `c_test_func'

2023-10-05 Thread sbezverk
After looking in cgo generated files, I found that in fact function “c_test_func” is defined in 2 places. 1: ./cgo.cgo2.c:29: int c_test_func(int c1, int c2) #line 3 "/nobackup/sbezverk/projects/go/worspace/cgo_test/cgo.go" #include extern int go_test_func(int

[go-nuts] cgo.go: multiple definition of `c_test_func'

2023-10-05 Thread sbezverk
I am getting: # command-line-arguments /sw/packages/xr/go/1.19.4/pkg/tool/linux_amd64/link: running gcc failed: exit status 1 /tmp/go-link-349950461/01.o: In function `c_test_func': /nobackup/sbezverk/projects/go/worspace/cgo_test/cgo.go:9: multiple definition of `c_test_func' /tmp/go-l

[go-nuts] Build test tag real life example

2023-10-04 Thread sbezverk
Hello, I saw there was some debates about having “test build tag” here: https://github.com/golang/go/issues/21360  and people were asking about real life scenario. Here is one with CGO code, initially I was planning to add stubs for C land calls into blah_test.go file. (I do not need to

Re: [go-nuts] cgo and dynamic linking of shared labraries

2023-09-26 Thread sbezverk
Related question: is it possible to replace golang's "link" tool with "ld"? It looks like "ld" has greater flexibility to address my requirements. Thank you in advance for your guidance. Serguei On 26/09/23, 12:32, "sbezverk" mailto:sbezv...@gmail.co

Re: [go-nuts] cgo and dynamic linking of shared labraries

2023-09-26 Thread sbezverk
the size limit and pretty much kills bash. I am starting to get this: ``` dev-1:/user/sbezverk/go_connect > ls -bash: /bin/ls: Argument list too long ``` For every internal bash command I try to execute. I was wondering if there is a keyword forcing the linker not to try to resolve everyth

[go-nuts] cgo and dynamic linking of shared labraries

2023-09-23 Thread sbezverk
Hello, Since I could not find the answer in the cgo documentation, I would really appreciate if somebody could help me to understand why when I build cgo code with calls to the shared library, the linker tries to find the shared library even though it is instructed to build dynamic binary

[go-nuts] Issue with regular expression processing

2022-12-05 Thread sbezverk
Hello, I came across a strange behavior in regular expression processing, please see the following simple code which is supposed to match the second line of data variable. https://go.dev/play/p/QPrNRuhCv8r The matching data starts at the beginning of the 3rd line so I expect the

[go-nuts] Refactor to use generics to have a single Make

2022-05-03 Thread sbezverk
Hello, I am starting to learn generics and I was wondering if the following code could be refactored to use genercis, in order to avoid using per type Make() method. https://go.dev/play/p/gE4Z6Zj19Is I have 3 identical structs, they are defined with different types and used in other

[go-nuts] efficiently reconstruct and use data structures encoded with gpb-kv

2021-07-02 Thread sbezverk
Hello, I am looking for some ideas about how efficiently use gpb-kv encoded data structure.  If each field of a data structure gets reconstructed with type assertion, I suspect that might cause some performance issues for a high rate data streams. Another concern is unknown structure of the

Re: [go-nuts] Custom Unmarshal multi level map

2020-07-29 Thread sbezverk
Thank you, I was suspecting that it was something simple I was missing. On 2020-07-29, 3:47 PM, "burak serdar" wrote: On Wed, Jul 29, 2020 at 1:42 PM sbezverk wrote: > > Hello, > > > > A bit of help would be much appreciated, her

[go-nuts] Custom Unmarshal multi level map

2020-07-29 Thread sbezverk
Hello, A bit of help would be much appreciated, here is the sample code: https://play.golang.org/p/FYEC7MwU1qQ I need to Unmarshal 3 levels map. The information is stored this was as a json doc and there is no way to flatten it.  This sample code works but since UnmarshalJSON method of

[go-nuts] Imp.ListenPacket fail for IPv6 address

2019-10-09 Thread 'Serguei Bezverkhi (sbezverk)' via golang-nuts
Hello, Here is the part of code where I attempt to listen for icmp packet in a namespace. The same code is used for IPv4 and IPv6, only proto and scr are differ depending on ipv4 or ipv6 mode. For IPv4 address code work as expected but for IPv6 ListenPacket fails. org, err :=

[go-nuts] syscall.SendMsg/RecvMsg

2019-03-15 Thread sbezverk
Hello, I am trying to pass a descriptor using syscall.SendMsg/RecvMsg and I noticed that inod for the second process is not the same as original, but according to Unix Networking API, inod should stay the same and only number of reference to inod should be incremented. Anybody successfully

Re: [go-nuts] Re: Ioctl Syscall with go and c

2018-08-26 Thread 'Serguei Bezverkhi (sbezverk)' via golang-nuts
Hi Jake, Ioctl implementation in unix package seems a bit limited, how do you pass for example a required struct if “func IoctlSetInt(fd int, req uint, value int)” allows only to accept int?? If this package had a func accepting uintptr as a parameter, then I guess that could work. Thank you

Re: [go-nuts] Re: Ioctl Syscall with go and c

2018-08-23 Thread 'Serguei Bezverkhi (sbezverk)' via golang-nuts
I copied the whole thing to https://github.com/sbezverk/vfio Running it without actual vfio/iommu might be problematic though. Before this specific ioctl can be run 2 open calls must succeed. See func main. Thank you for looking into this problem Serguei Sent from my iPhone > On Aug 23, 2

Re: [go-nuts] Re: Ioctl Syscall with go and c

2018-08-23 Thread 'Serguei Bezverkhi (sbezverk)' via golang-nuts
Hello Jake, Apologies about formatting, here is correctly formatted code: // GetGroupFD gets File descriptor for a specified by PCI address device func GetGroupFD(group int, pciDevice string) (int, error) { buffer := make([]byte, len(pciDevice)+1) for i, c :=

Re: [go-nuts] Re: Ioctl Syscall with go and c

2018-08-23 Thread 'Serguei Bezverkhi (sbezverk)' via golang-nuts
I changed code a little bit to be able to examine variables: func GetGroupFD(group int, pciDevice *string) (int, error) { ioctlId := 0x3b6a var buffer uintptr buffer = uintptr(unsafe.Pointer(pciDevice)) device, _, errno := syscall.Syscall( syscall.SYS_IOCTL,

[go-nuts] Ioctl Syscall with go and c

2018-08-23 Thread 'Serguei Bezverkhi (sbezverk)' via golang-nuts
Hello, I am converting some C code to Go and hit an issue with one particular Syscall: In C: device = ioctl(group, 0x3b6a, path); where path is char[N] In Go: ioctlId := 0x3b6a device, _, errno := syscall.Syscall( syscall.SYS_IOCTL, uintptr(group),

[go-nuts] Reliable dns client library

2018-05-16 Thread Serguei Bezverkhi (sbezverk)
Hello, Appreciate if somebody could recommend reliable dns client library supporting AXFR type of requests. I was using miekg/dns and I see some strange results. Thank you Serguei -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe

[go-nuts] Running golang compiled binary on QNX

2018-01-30 Thread Serguei Bezverkhi (sbezverk)
Hello, I was wondering if anybody managed to get golang compiled binary to run on 32-bit QNX? I compiled it with GOARCH=386 GOOS=linux go build -o blah But when I start it in QNX I get core dump. I double check and the time of executable matches type of native qnx binaries. Appreciate any

[go-nuts] Getting Uid/Gid for a folder

2017-07-31 Thread Serguei Bezverkhi (sbezverk)
Hello, I am having trouble getting GID for a folder. I checked os.Stat api but it returns only permissions, there is no Uid or Gid. stat /mnt/disks/vol2 File: ‘/mnt/disks/vol2’ Size: 6 Blocks: 0 IO Block: 4096 directory Device: fc12h/64530dInode: 64