Re: [go-nuts] can't read data from the tun device

2023-06-15 Thread akalio ja
GO111MODULE="" GOARCH="amd64" GOBIN="" GOCACHE="/root/.cache/go-build" GOENV="/root/.config/go/env" GOEXE="" GOEXPERIMENT="" GOFLAGS="" GOHOSTARCH="amd64" GOHOSTOS="linux" GOINSECURE="" GOMODCACHE="/root/go/pkg/mod" GONOPROXY="" GONOSUMDB="" GOOS="linux" GOPATH="/root/go" GOPRIVATE=""

[go-nuts] Re: tool for ast graph visualization

2023-06-15 Thread alex-coder
Thank you so much ! четверг, 15 июня 2023 г. в 13:28:52 UTC+3, Vraj Reshamdalal: > Hi alex-coder, > To get ast for GO code in a json format you can try a web tool: > https://astexplorer.net/ > or > https://github.com/asty-org/asty > > Thanks, > Vraj > > On Thursday, June 15, 2023 at 9:31:54 AM

Re: [go-nuts] can't read data from the tun device

2023-06-15 Thread Ian Lance Taylor
What version of Go are you using? Ian On Thu, Jun 15, 2023, 5:32 AM akalio ja wrote: > func openTun(ch chan int, timer *time.Timer) { > > fd, err := unix.Open("/dev/net/tun", unix.O_RDWR|unix.O_NONBLOCK, 0) > if err != nil { > panic(err) > } > defer unix.Close(fd) > >

[go-nuts] can't read data from the tun device

2023-06-15 Thread akalio ja
func openTun(ch chan int, timer *time.Timer) { fd, err := unix.Open("/dev/net/tun", unix.O_RDWR|unix.O_NONBLOCK, 0) if err != nil { panic(err) } defer unix.Close(fd) var ifr struct { name [16]byte flags uint16 _ [22]byte }

[go-nuts] Re: tool for ast graph visualization

2023-06-15 Thread Vraj Reshamdalal
Hi alex-coder, To get ast for GO code in a json format you can try a web tool: https://astexplorer.net/ or https://github.com/asty-org/asty Thanks, Vraj On Thursday, June 15, 2023 at 9:31:54 AM UTC+5:30 alex-coder wrote: > Xa, context is the king on a field :-) > > You gave a good sample, and

Re: [go-nuts] Unexpected circular type definition limitation

2023-06-15 Thread Brian Candler
> You can always solve name spacing issues by splitting it up into separate packages. Or type aliases: https://go.dev/play/p/Slhgs8SLyo6 On Thursday, 15 June 2023 at 09:47:39 UTC+1 Axel Wagner wrote: > Type declarations in functions are only scoped from the point of their > declaration until

Re: [go-nuts] Unexpected circular type definition limitation

2023-06-15 Thread 'Axel Wagner' via golang-nuts
Type declarations in functions are only scoped from the point of their declaration until the end of the function. So the reason you can not do the recursive type definition in a function is that at the point of the first declaration, the second is not yet in scope. Package scoped declarations are

Re: [go-nuts] Unexpected circular type definition limitation

2023-06-15 Thread Christophe Meessen
The following playground example shows the problem: https://go.dev/play/p/1kC2j57M_fW Le 15/06/2023 à 10:28, Jan Mercl a écrit : On Thu, Jun 15, 2023 at 10:16 AM christoph...@gmail.com wrote: It is possible to define two structures globally with mutual type dependency as this: type A

Re: [go-nuts] Unexpected circular type definition limitation

2023-06-15 Thread Jan Mercl
On Thu, Jun 15, 2023 at 10:16 AM christoph...@gmail.com wrote: > It is possible to define two structures globally with mutual type dependency > as this: > > type A struct { > B []B > } > > type B struct { > A A[] > } > > but I just noticed that we can't do that inside a function: > >

[go-nuts] Unexpected circular type definition limitation

2023-06-15 Thread christoph...@gmail.com
It is possible to define two structures globally with mutual type dependency as this: type A struct { B []B } type B struct { A A[] } but I just noticed that we can't do that inside a function: func Foo() { type A struct { B []B } type B struct { A A[]