#sourcemaps test
1 messages ยท Page 1 of 1 (latest)
A small script to test it:
#!/bin/sh
(mkdir -p test; cd test
dagger init --sdk=go --name=test .
cat <<EOF > main.go
package main
type Test struct {}
EOF
dagger init --sdk=go dep
cat <<EOF > dep/main.go
package main
import "context"
type Dep struct {
FieldDef string
}
func (m *Dep) FuncDef(
arg1 string,
arg2 string, // +optional
) string {
return ""
}
type MyEnum string
const (
MyEnumA MyEnum = "MyEnumA"
MyEnumB MyEnum = "MyEnumB"
)
type MyInterface interface {
DaggerObject
Do(ctx context.Context, val int) (string, error)
}
func (m *Dep) Collect(MyEnum, MyInterface) error {
// force all the types here to be collected
return nil
}
EOF
dagger install ./dep
grep "Dep struct" internal/dagger/dagger.gen.go
)
According to the test, the output should be
type Dep struct { // dep \(../../dep/main.go:5:6\)
My output is
type Dep struct { // dep \(../../main.go:5:6\)
hm okay, my guess
there are two parts of that generation
there's some in namespaceSourcemap
there's also the ModuleRelPath
which is used to process the Filelink
so potentially one of those is wrong
i wonder if when generating the typedefs we are not setting the ModuleConfig in your branch? since they got split to separate binaries?
that is my best guess ๐ค
Yes, I tried to understand this part and find the issue.
That's where I started to run the same example using this time not my branch but the v0.18.19. And when I'm running it, I have the same result than my branch, not the results from the tests ๐
I think I don't understand how the test can pass. All the tests I'm doing, with v0.18.19, with main, with my branch, in all cases I have ../../main.go instead of ../../dep/main.go
Either there's an other bug, either there's something wrong in the way I'm using it
๐
ok, I got it. The issue is ... ๐ฅ ... git
By initializing a git repository at the level of my root module, the sourcemap is now right with ../../dep/main.go (at least with a plain dagger)