diff --git a/crates/go/src/lib.rs b/crates/go/src/lib.rs index bf754f81b..4caf53a04 100644 --- a/crates/go/src/lib.rs +++ b/crates/go/src/lib.rs @@ -1326,7 +1326,10 @@ func {camel}({go_params}) {go_results} {{ ( if abi::guest_export_needs_post_return(resolve, func) { - format!("{PINNER} := &runtime.Pinner{{}}") + format!( + "{PINNER} := &runtime.Pinner{{}} + defer {PINNER}.Unpin()" + ) } else { String::new() },