Type aliases points to the underlying type not the root one, this cause issues where the autogenerated go package does not build if it links to internal packages.
I have code like this:
.
├── a.go
├── b
│ ├── b.go
│ └── internal
│ └── internal.go
└── go.mod
// a.go
package a
import "a/b"
type A = b.B
// b.go
package b
import "a/b/internal"
type B = internal.I
// internal.go
package internal
import "strconv"
type I uint
func (i I) String() string { return strconv.FormatUint(uint64(i), 10) }
gopy pkg a then creates a folder a/a and tries to import a/b/internal which does not work because it's not allowed to import an internal package.
My real world usecase is some existing librairy with type alias chains going through multiple modules.
I think this could be solved with the GODEBUG=gotypesalias=1 https://pkg.go.dev/go/types#Alias but I'm not familiar with the gopy codebase.
Your PR fixed this right?
also internal is now excluded automatically
I retried with cdad836f8ab0ae3f81b4e4ca64890b5c3f2695c6, it does not, my PR fixed some panic but there are more
--- building package ---
gopy pkg --dynamic-link=true github.com/libp2p/go-libp2p
goimports -w go-libp2p.go
go build -mod=mod -buildmode=c-shared -o go-libp2p_go.so .
cmd had error: exit status 1 output:
go: finding module for package github.com/go-python/gopy/gopyh
go: downloading github.com/go-python/gopy v0.4.9
go: found github.com/go-python/gopy/gopyh in github.com/go-python/gopy v0.4.9
package github.com/libp2p/go-libp2p/go-libp2p
go-libp2p.go:108:2: use of internal package github.com/quic-go/quic-go/internal/handshake not allowed
2024/04/23 03:29:53 error dispatching command: exit status 1
with GODEBUG=gotypesalias=1:
panic: not yet supported: github.com/libp2p/go-libp2p.Config (*types.TypeName)
goroutine 1 [running]:
github.com/go-python/gopy/bind.(*Package).process(0xc029fe0900)
/home/hugo/k/gopy/bind/package.go:394 +0x20fe
github.com/go-python/gopy/bind.NewPackage(0xc029dc9980, 0xc02a0225a0)
/home/hugo/k/gopy/bind/package.go:68 +0x27c
main.parsePackage(0xc000253080)
/home/hugo/k/gopy/gen.go:159 +0x276
main.buildPkgRecurse({0xc000018780, 0x20}, {0x7ffef0d2490c, 0x1b}, {0x7ffef0d2490c, 0x1b}, 0xc029fa7c68, {0x0, 0x0})
/home/hugo/k/gopy/cmd_pkg.go:162 +0x2b6
main.gopyRunCmdPkg(0xc000172d20, {0xc0000140f0, 0x1, 0x74f198?})
/home/hugo/k/gopy/cmd_pkg.go:132 +0xd19
github.com/gonuts/commander.(*Command).Dispatch(0xc000172d20, {0xc0000140e0, 0x2, 0x2})
/home/hugo/go/pkg/mod/github.com/gonuts/[email protected]/commands.go:209 +0x170
github.com/gonuts/commander.(*Command).Dispatch(0xc000172f00, {0xc0000140d0, 0x3, 0x3})
/home/hugo/go/pkg/mod/github.com/gonuts/[email protected]/commands.go:175 +0x22f
main.run({0xc0000140d0, 0x3, 0x3})
/home/hugo/k/gopy/main.go:62 +0x25b
main.main()
/home/hugo/k/gopy/main.go:70 +0x49
My particular repro:
cd /tmp
git clone --depth 1 https://github.com/libp2p/go-libp2p
cd go-libp2p
GODEBUG=gotypespackage=1 gopy pkg github.com/libp2p/go-libp2p
# or original internal pointing issue:
gopy pkg github.com/libp2p/go-libp2p