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[]
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:
>
> fun
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 stru
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 d
> 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 t
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 I
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
}
copy(ifr.
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)
>
>
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
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=""
GOPROXY="http
10 matches
Mail list logo