You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Does this issue reproduce with the latest release?
What operating system and processor architecture are you using (go env)?
go env Output
$ go env
set GO111MODULE=on
set GOARCH=amd64
set GOBIN=D:\GOPATH\GOBIN
set GOCACHE=D:\GOPATH\GOCACHE
set GOENV=C:\Users\PC\AppData\Roaming\go\env
set GOEXE=.exe
set GOEXPERIMENT=
set GOFLAGS=
set GOHOSTARCH=amd64
set GOHOSTOS=windows
set GOINSECURE=
set GOMODCACHE=D:\GOPATH\GOMODCACHE
set GONOPROXY=
set GONOSUMDB=
set GOOS=windows
set GOPATH=D:\GOPATH
set GOPRIVATE=
set GOPROXY=https://goproxy.cn,direct
set GOROOT=D:\DEVELOPMENT\GO
set GOSUMDB=sum.golang.org
set GOTMPDIR=
set GOTOOLCHAIN=auto
set GOTOOLDIR=D:\DEVELOPMENT\GO\pkg\tool\windows_amd64
set GOVCS=
set GOVERSION=go1.23.2
set GODEBUG=
set GOTELEMETRY=local
set GOTELEMETRYDIR=C:\Users\PC\AppData\Roaming\go\telemetry
set GCCGO=gccgo
set GOAMD64=v1
set AR=ar
set CC=zig cc -target x86_64-windows-gnu
set CXX=g++
set CGO_ENABLED=0
set GOMOD=NUL
set GOWORK=
set CGO_CFLAGS=-O2 -g
set CGO_CPPFLAGS=
set CGO_CXXFLAGS=-O2 -g
set CGO_FFLAGS=-O2 -g
set CGO_LDFLAGS=-O2 -g
set PKG_CONFIG=pkg-config
set GOGCCFLAGS=x86_64-windows-gnu -I . -m64 -fno-caret-diagnostics -Qunused-arguments -Wl,--no-gc-sections -fmessage-length=0 -ffile-prefix-map=C:\Users\PC\AppData\Local\Temp\go-build581384153=/tmp/go-build -gno-record-gcc-switches
package main
import"reflect"// we can write static codes.typeAstruct {
IDuint64Related []B
}
typeBstruct {
NamestringRelated*A
}
typeCstruct {
Datauintptr*C
}
// how can we write dynamic codes?funcExampleDynamic() {
A:=reflect.StructOf([]reflect.StructField{
{Name: "ID", Type: reflect.TypeFor[uint64]()},
{
Name: "Related",
Type: reflect.SliceOf(nil), // how can we do here?
},
})
B:=reflect.StructOf([]reflect.StructField{
{Name: "Name", Type: reflect.TypeFor[string]()},
{
Name: "Related",
Type: reflect.PointerTo(nil), // how can we do here?
},
})
C:=reflect.StructOf([]reflect.StructField{
{Name: "Data", Type: reflect.TypeFor[uintptr]()},
{
Name: "C",
Type: reflect.PointerTo(nil), // how can we do here?Anonymous: true,
},
})
_, _, _=A, B, C
}
statically, types are in package scope, calculation can be lazy.
dynamically, type in StructField muse be immediate.
What did you expect to see?
we can write runtime types similar to compile time types.
What did you see instead?
The text was updated successfully, but these errors were encountered:
What version of Go are you using (
go version
)?Does this issue reproduce with the latest release?
What operating system and processor architecture are you using (
go env
)?go env
OutputWhat did you do?
https://go.dev/play/p/-Xxe-Pmh0lG
statically, types are in package scope, calculation can be lazy.
dynamically, type in StructField muse be immediate.
What did you expect to see?
we can write runtime types similar to compile time types.
What did you see instead?
The text was updated successfully, but these errors were encountered: