Fix Go tests to run in module mode
Stop using relative imports and add a go.mod file. Tested against Go 1.6 through Go pre-1.13, and gccgo.
This commit is contained in:
parent
b04cc850ab
commit
8a1c09e280
173 changed files with 298 additions and 227 deletions
|
|
@ -125,6 +125,8 @@ class GO:public Language {
|
|||
String *prefix_option;
|
||||
// -fgo-pkgpath option.
|
||||
String *pkgpath_option;
|
||||
// Prefix for translating %import directive to import statements.
|
||||
String *import_prefix;
|
||||
// Whether to use a shared library.
|
||||
bool use_shlib;
|
||||
// Name of shared library to import.
|
||||
|
|
@ -204,6 +206,7 @@ public:
|
|||
go_prefix(NULL),
|
||||
prefix_option(NULL),
|
||||
pkgpath_option(NULL),
|
||||
import_prefix(NULL),
|
||||
use_shlib(false),
|
||||
soname(NULL),
|
||||
intgo_type_size(0),
|
||||
|
|
@ -293,6 +296,15 @@ private:
|
|||
} else {
|
||||
Swig_arg_error();
|
||||
}
|
||||
} else if (strcmp(argv[i], "-import-prefix") == 0) {
|
||||
if (argv[i + 1]) {
|
||||
import_prefix = NewString(argv[i + 1]);
|
||||
Swig_mark_arg(i);
|
||||
Swig_mark_arg(i + 1);
|
||||
i++;
|
||||
} else {
|
||||
Swig_arg_error();
|
||||
}
|
||||
} else if (strcmp(argv[i], "-use-shlib") == 0) {
|
||||
Swig_mark_arg(i);
|
||||
use_shlib = true;
|
||||
|
|
@ -743,7 +755,11 @@ private:
|
|||
if (modname) {
|
||||
if (!Getattr(go_imports, modname)) {
|
||||
Setattr(go_imports, modname, modname);
|
||||
Printv(f_go_imports, "import \"", modname, "\"\n", NULL);
|
||||
Printv(f_go_imports, "import \"", NULL);
|
||||
if (import_prefix) {
|
||||
Printv(f_go_imports, import_prefix, "/", NULL);
|
||||
}
|
||||
Printv(f_go_imports, modname, "\"\n", NULL);
|
||||
}
|
||||
imported_package = modname;
|
||||
saw_import = true;
|
||||
|
|
@ -6983,9 +6999,10 @@ const char * const GO::usage = "\
|
|||
Go Options (available with -go)\n\
|
||||
-cgo - Generate cgo input files\n\
|
||||
-no-cgo - Do not generate cgo input files\n\
|
||||
-gccgo - Generate code for gccgo rather than 6g/8g\n\
|
||||
-gccgo - Generate code for gccgo rather than gc\n\
|
||||
-go-pkgpath <p> - Like gccgo -fgo-pkgpath option\n\
|
||||
-go-prefix <p> - Like gccgo -fgo-prefix option\n\
|
||||
-import-prefix <p> - Prefix to add to %import directives\n\
|
||||
-intgosize <s> - Set size of Go int type--32 or 64 bits\n\
|
||||
-package <name> - Set name of the Go package to <name>\n\
|
||||
-use-shlib - Force use of a shared library\n\
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue