@@ -29,6 +29,10 @@ type importResult struct {
29
29
var runtimeGenFS embed.FS
30
30
31
31
// TODO: may apply tags
32
+ // importRuntimeDep detect if the target package already
33
+ // has github.com/xhd2015/xgo/runtime as dependency,
34
+ // if not, dynamically modify the go.mod to include that,
35
+ // and add a blank import in the main package
32
36
func importRuntimeDep (test bool , goroot string , goBinary string , goVersion * goinfo.GoVersion , absModFile string , xgoSrc string , projectDir string , modRootRel []string , mainModule string , mod string , args []string ) (* importResult , error ) {
33
37
if mainModule == "" {
34
38
// only work with module
@@ -64,7 +68,6 @@ func importRuntimeDep(test bool, goroot string, goBinary string, goVersion *goin
64
68
return nil , err
65
69
}
66
70
67
- pkgArgs := getPkgArgs (args )
68
71
tmpRoot , tmpProjectDir , err := createWorkDir (projectRoot )
69
72
if err != nil {
70
73
return nil , err
@@ -84,6 +87,7 @@ func importRuntimeDep(test bool, goroot string, goBinary string, goVersion *goin
84
87
}
85
88
}
86
89
90
+ pkgArgs := getPkgArgs (args )
87
91
fileReplace , err := addBlankImports (goroot , goBinary , projectDir , pkgArgs , test , tmpProjectDir )
88
92
if err != nil {
89
93
return nil , err
@@ -171,8 +175,10 @@ type Overlay struct {
171
175
172
176
type dependencyInfo struct {
173
177
modReplace map [string ]string
174
- mod string
175
- modfile string // alternative go.mod
178
+ // the -mod flag
179
+ mod string
180
+ // the -modfile flag
181
+ modfile string // alternative go.mod
176
182
}
177
183
178
184
func createWorkDir (projectRoot string ) (tmpRoot string , tmpProjectDir string , err error ) {
0 commit comments