diff --git a/CHANGES.current b/CHANGES.current index 1945e9292..ca7503d41 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -5,6 +5,9 @@ See the RELEASENOTES file for a summary of changes in each release. Version 3.0.0 (in progress) ============================ +2014-01-21: ianlancetaylor + [Go] Add %go_import directive. + 2014-01-21: ianlancetaylor [Go] Add support for Go 1.3, not yet released. diff --git a/Doc/Manual/Go.html b/Doc/Manual/Go.html index 43bfc6971..240db2b61 100644 --- a/Doc/Manual/Go.html +++ b/Doc/Manual/Go.html @@ -666,9 +666,31 @@ func (arg SwigcptrWrapped_MyClass) GetAValue() (int, bool) { few, then you might as well define your own struct that includes the swig-wrapped object, instead of adding methods to the swig-generated object.
-This only works if your wrappers do not need to import other go modules. -There is at present no way to insert import statements in the correct place -in swig-generated go. If you need to do that, you must put your go code -in a separate file.
+If you need to import other go packages, you can do this with
+%go_import. For example,
+%go_import("fmt", _ "unusedPackage", rp "renamed/package")
+
+%insert(go_wrapper) %{
+
+func foo() {
+ fmt.Println("Some string:", rp.GetString())
+}
+
+// Importing the same package twice is permitted,
+// Go code will be generated with only the first instance of the import.
+%go_import("fmt")
+
+%insert(go_wrapper) %{
+
+func bar() {
+ fmt.Println("Hello world!")
+}
+
+%}
+
+